User Tools

Site Tools


linux:ubuntu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:ubuntu [2023/11/02 08:17] – [Ubuntu basic commands] skipidarlinux:ubuntu [2024/05/15 05:10] (current) – [Performance Monitoring commands] skipidar
Line 22: Line 22:
 ==== Essencial Commands ==== ==== Essencial Commands ====
 The essencial linux commands are listed under: [[http://docstore.mik.ua/orelly/linux/run/ch04_01.htm]] The essencial linux commands are listed under: [[http://docstore.mik.ua/orelly/linux/run/ch04_01.htm]]
 +
 +
 +<sxh shell>
 +ls # list contents of a directory.  ls -a show hidden files.
 +sudo # "super-user do" (grants administrator rights) 
 +sudo -i -u <username>  # login as another user e.g. root
 +cd # change directory
 +chmod # change file access permissions
 +chown # change file and group ownership
 +cp # copy
 +mv # move
 +rm # remove
 +cat # concatenate files (dump to screen)
 +emacs # text editor
 +fdisk # partition table manipulator
 +free -h # show free storage
 +df -h # disk free (remaining / used disk space, disk size in percent, human readable)
 +ncdu  # disk space visualizer
 +sudo du -h ./* | sort -h  # folders and files size in current dir. Sorted.
 +users # users currently logged in
 +useradd # add a user
 +usermod # modify existing user
 +userdel # delete user
 +uname # show system data (try uname -a)
 +cat /etc/*-release   # shows the release name and other infos about the installed distribution
 +cat /proc/version # shows distribution version, name etc.
 +cat /proc/version # shows mode distribution data
 +top # show current running processes
 +kill # kill process by PID
 +touch # create new, empty, file
 +passwd # change user password
 +ping -c [COUNT] # ping a network device or location (ping -c 1 google.com)
 +more # show output one screen at a time
 +locate # indexed search ("sudo updatedb" updates indexed database)
 +find # search in the current directory and subdirectories
 +ln -s myFile.txt myLink.txt   # symbolic link
 +unzip /path/to/file.zip -d /targetdir # unzip
 +nohup # executes a command from shell, so that it keeps on running after shell exits.
 +& # When placed at the end of a command, execute that command in the background. "vim &"
 +fg # bring theprocess back to the foreground. jobs; fg %1
 +
 +# enable the NTP server for time syncronization
 +sudo timedatectl set-ntp on
 +timedatectl
 +
 +# clear /var/log/journal/ files, leave only data of last 10d
 +sudo journalctl --vacuum-time=10d
 + 
 +# show 10 largest folders, sorted by size, in human friendly size scala
 +du -sh * | sort -hr | head -n10
 +4.2G    var
 +2.0G    usr
 +914M    snap
 +339M    opt
 +133M    data
 +119M    boot
 +6.1M    etc
 +1.4M    home
 +1.1M    run
 +364K    root
 + 
 + 
 +# example of finding files in 2 subfolders 
 +# and writing a cat command with them into the file replace.sh
 +# man pages https://man7.org/linux/man-pages/man1/find.1.html
 +find . \
 + -name "DocxToPdf.bat" -path "*/Certificates/*" -o \
 + -name "DocxToPdf.ps1" -path "*/Zeugnisse/*"  \
 + -exec echo "cat /mnt/Temp/DocxToPdf.bat > \"{}\"" > replace.sh \;
 +
 +# you can invert the path with "-not"
 +
 +find . \
 + -name "DocxToPdf.bat"  -not  -path "*/Certificates/*" -o \
 + -name "DocxToPdf.ps1"  -not  -path "*/Zeugnisse/*"  \
 + -exec echo "cat /mnt/Temp/DocxToPdf.bat > \"{}\"" > replace.sh \;
 +
 +</sxh>
 +
 +
  
 ==grep== ==grep==
Line 107: Line 187:
 </VirtualHost> </VirtualHost>
 </code> </code>
 +
 +
 +==== Performance Monitoring commands ====
 +
 +{{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/sharex/c12ezuvdZY.png}}
 +
 +how to diagnose a mysterious process that’s taking too much CPU, memory, IO, etc? 
 + 
 +The diagram below illustrates helpful tools in a Linux system. 
 +
 +<sxh shell>
 +vmstat # reports information about processes, memory, paging, block IO, traps, and CPU activity. 
 +iostat # reports CPU and input/output statistics of the system. 
 +netstat # displays statistical data related to IP, TCP, UDP, and ICMP protocols. 
 +lsof # lists open files of the current system. 
 +pidstat # monitors the utilization of system resources by all or specified processes, including CPU, memory, device IO, task switching, threads, etc. 
 +</sxh>
 + 
 +
 + 
 +Credit: Diagram by Brendan Gregg 
  
  
Line 1377: Line 1478:
  
    dig -t NS google.com @1.1.1.1 ANY    dig -t NS google.com @1.1.1.1 ANY
 +
 +
 +===== Upgrading packages =====
 +
 +
 +==== Python3 ====
 +
 +<sxh shell>
 +
 +# install new version of python
 +sudo add-apt-repository ppa:deadsnakes/ppa
 +sudo apt update
 +sudo apt install python3.12
 +
 +# setting the python12 as default version of python
 +sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
 +
 +# gives python3.12.2
 +python3 --version
 +</sxh>
  
linux/ubuntu.1698913073.txt.gz · Last modified: by skipidar