linux:ubuntu
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:ubuntu [2023/11/02 07:53] – [Ubuntu basic commands] skipidar | linux: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:// | The essencial linux commands are listed under: [[http:// | ||
| + | |||
| + | |||
| + | <sxh shell> | ||
| + | ls # list contents of a directory. | ||
| + | sudo # " | ||
| + | sudo -i -u < | ||
| + | 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 / | ||
| + | cat / | ||
| + | cat / | ||
| + | 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" | ||
| + | find # search in the current directory and subdirectories | ||
| + | ln -s myFile.txt myLink.txt | ||
| + | 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 / | ||
| + | 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:// | ||
| + | find . \ | ||
| + | -name " | ||
| + | -name " | ||
| + | -exec echo "cat / | ||
| + | |||
| + | # you can invert the path with " | ||
| + | |||
| + | find . \ | ||
| + | -name " | ||
| + | -name " | ||
| + | -exec echo "cat / | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| ==grep== | ==grep== | ||
| Line 107: | Line 187: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ==== Performance Monitoring commands ==== | ||
| + | |||
| + | {{https:// | ||
| + | |||
| + | 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/ | ||
| + | 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. | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | Credit: Diagram by Brendan Gregg | ||
| Line 406: | Line 507: | ||
| sudo chmod a+x mysript.sh | sudo chmod a+x mysript.sh | ||
| </ | </ | ||
| - | ==== Ubuntu basic commands ==== | ||
| - | <sxh shell> | ||
| - | ls # list contents of a directory. | ||
| - | sudo # " | ||
| - | sudo -i -u < | ||
| - | 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 / | ||
| - | cat / | ||
| - | cat / | ||
| - | 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" | ||
| - | find # search in the current directory and subdirectories | ||
| - | ln -s myFile.txt myLink.txt | ||
| - | 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 | ||
| - | |||
| - | # clear / | ||
| - | 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:// | ||
| - | find . \ | ||
| - | -name " | ||
| - | -name " | ||
| - | -exec echo "cat / | ||
| - | |||
| - | # you can invert the path with " | ||
| - | |||
| - | find . \ | ||
| - | -name " | ||
| - | -name " | ||
| - | -exec echo "cat / | ||
| - | |||
| - | </ | ||
| ==== CPU utilization ==== | ==== CPU utilization ==== | ||
| Line 1450: | 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: | ||
| + | sudo apt update | ||
| + | sudo apt install python3.12 | ||
| + | |||
| + | # setting the python12 as default version of python | ||
| + | sudo update-alternatives --install / | ||
| + | |||
| + | # gives python3.12.2 | ||
| + | python3 --version | ||
| + | </ | ||
linux/ubuntu.1698911589.txt.gz · Last modified: by skipidar
