Cộng đồng chia sẻ tri thức Lib24.vn

101 Linux commands

413023e635786051955bc1859d73cff5
Gửi bởi: Phạm Thọ Thái Dương 19 tháng 11 2020 lúc 11:37:57 | Được cập nhật: 7 giờ trước (19:12:25) Kiểu file: PDF | Lượt xem: 384 | Lượt Download: 2 | File size: 0.068433 Mb

Nội dung tài liệu

Tải xuống
Link tài liệu:
Tải xuống

Các tài liệu liên quan


Có thể bạn quan tâm


Thông tin tài liệu

101 Useful Linux Commands - haydenjames.io Some of these commands require elevated permissions (sudo) to run. Enjoy! 1. Execute the previous command used: !! 2. Execute a previous command starting with a specific letter. Example: !s 3. Short way to copy or backup a file before you edit it. For example, copy nginx.conf cp nginx.conf{,.bak} 4. Toggle between current directory and last directory cd 5. Move to parent (higher level) directory. Note the space! cd .. 6. Go to home directory cd ~ 7. Go to home directory cd $HOME 8. Go to home directory (when used alone) cd 9. Set permissions to 755. Corresponds to these permissions: (-rwx-r-x-r-x), arranged in this sequence: (owner-group-other) chmod 755 10. Add execute permission to all users. chmod a+x 11. Changes ownership of a file or directory to . chown 12. Make a backup copy of a file (named file.backup) cp .backup 13. Copy file1, use it to create file2 cp 14. Copy directory1 and all its contents (recursively) into directory2 cp -r / 15. Display date date 16. Zero the sdb drive. You may want to use GParted to format the drive afterward. You need elevated permissions to run this (sudo). dd if=/dev/zero of=/dev/sdb 17. Display disk space usage df -h 18. Take detailed messages from OS and input to text file dmesg>dmesg.txt 19. Display a LOT of system information. I usually pipe output to less. You need elevated permissions to run this (sudo). dmidecode 20. Display BIOS information. You need elevated permissions to run this (sudo). dmidecode -t 0 21. Display CPU information. You need elevated permissions to run this (sudo). dmidecode -t 4 22. Search for installed packages related to Apache dpkg –get-selections | grep apache 23. Shows you where in the /filesystem the package components were installed dpkg -L 24. Display detailed disk use for each subdirectory du / -bh | less 25. Print the environment variable PATH echo $PATH 26. Display environment variables like USER, LANG, SHELL, PATH, TERM, etc. env 27. Opens a picture with the Eye of Gnome Image Viewer eog 28. Quit the terminal (or give up super-powers if you’ve previously done sudo su) exit 29. Display memory usage free 30. Easy way to view all the system logs. gnome-system-log 31. Search through file(s) and display lines containing matching string grep 32. Get the number of seconds since the OS was started grep btime /proc/stat | grep -Eo “[[:digit:]]+” 33. Display the last 1000 commands history | less 34. Display the name of the local host hostname 35. Display time. hwclock –show 36. Display user id (uid) and group id (gid) id 37. Display your local IP address and netmask ifconfig 38. Wireless network interface iwconfig 39. Display wireless network information iwlist 40. Kill process by name. You need elevated permissions to run this (sudo). killall process 41. Get the date and time of the last system shutdown last -x | grep shutdown | head -1 | grep -Eo “[A-Z][a-z]{2} [[:digit:] ][[:digit:]] [[:digit:]]{2}:[[:digit:]]{2}” 42. Quit shell session (only for a shell you’ve logged into like one of the virtual consoles) logout 43. List non-hidden /files and subfolders in current directory (like dir for windows). Use -R for recursive and -a to include hidden /files. ls 44. Display file access permissions for all /files in the current directory. The format for permissions is drwxrwxrwx where the order is owner-group-other and the numeric values are read=4, write=2, execute=1. ls -l 45. List all available applications, in case you’ve forgotten how to open Open Office Writer or another application from the terminal (oowriter) ls /usr/bin | less 46. Display more networking information lshw -C network 47. Display kernel modules currently loaded lsmod 48. Display sound, video, and networking hardware lspci -nv | less 49. Display usb-connected hardware lsusb 50. Read the command’s man page (manual) man 51. Create new directory at specified location mkdir 52. Move file to specified directory mv 53. Rename file1 to file2 mv 54. Display routing table netstat -rn 55. Print environmental variables printenv 56. List the processes currently running by this user. There are many useful options, view them with ps –help ps -Af 57. Print working directory pwd 58. Delete file rm 59. Delete directory and all it’s contents rm -rf 60. Removes all /files that end in txt in current directory rm *.txt 61. Delete directory (will only work if it’s empty) rmdir 62. Display your default gateway listed under “default” route 63. Completely destroy all traces of the file. This takes a while. -n 7 means seven overwrites, -z means zero the bits afterward to hide shredding, -u means delete the file when done, and -v means verbose. shred -zuv -n 7 64. Shutdown now. shutdown -h now 65. Restart now. shutdown -r now 66. Log into remote computer ssh 67. Open the root shell, giving yourself superuser permissions until you relegate your powers with exit. Unlike sudo su which does the same thing, this method of starting the root shell is uncorrupted by a user’s environmental variables. sudo -i 68. Open the root shell, like sudo -i, but this method retains the user’s environmental variables. Relegate superuser permissions and return to normal shell with exit. sudo su 69. Creates a compressed archive of the specified directory and all /files/directories under it. tar czf .tgz 70. Expand the contents of a compressed archive and extract to current directory. tar zxvf 71. List current processes by cpu use. This is very useful. Press q to quit and h for help. top 72. Create an empty file if it doesn’t exist touch 73. Display the name of the current terminal tty 74. Display your linux kernel uname -a 75. Display your machine’s processor architecture uname -m 76. Returns one-line synopsis from the command’s man page whatis 77. Returns the location of the program in the /filesystem whereis 78. Returns the application’s path which 79. Display the users logged into the machine who 80. Display your login name whoami 81. This will display the output of test.log as it is being written to by another program tail –follow test.log 82. If you’ve just navigated to a directory shell and want to open a file or application IN that directory. Just use this command followed by the filename eg. ./filename.txt 83. Escape operator. Use it before a space if you’re trying to open a file that has whitespace in the name. \ 84. The tilde represents your home directory. ~ 85. Run any command when the system load is low batch 86. Display cpu info cat /proc/cpuinfo 87. Display memory usage cat /proc/meminfo 88. Display networking devices cat /proc/net/dev 89. Display performance information cat /proc/uptime 90. Display kernel version cat /proc/version 91. Display file contents cat 92. List partition tables fdisk -l 93. Show the properties/compression of a file or package file 94. Find a file. Search Linux /filesystem for a file name. find / -name 95. To create a *.gz compressed file gzip test.txt 96. To uncompress a *.gz file gzip -d test.txt.gz 97. Display compression ratio of the compressed file using gzip -l $ gzip -l *.gz 98. Output file status stat filename.txt 99. Download a file from the internet wget http://remote_file_url 100. Show list of last 10 logged in users. last -n 10 101. Display a tree of processes pstree Note: If you are pasting a command from above that includes a “ or ‘ and it does not work, you may have to re-type those quotes in shell manually. © 2011 – 2016 Hayden James. Do not republish without permission. [email protected]