Guest User

Untitled

a guest
May 12th, 2019
214
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Linux Terminal Command Reference
  2. System Info
  3.  
  4. date – Show the current date and time
  5. cal – Show this month's calendar
  6. uptime – Show current uptime
  7. w – Display who is online
  8. whoami – Who you are logged in as
  9. finger user – Display information about user
  10. uname -a – Show kernel information
  11. cat /proc/cpuinfo – CPU information
  12. cat /proc/meminfo – Memory information
  13. df -h – Show disk usage
  14. du – Show directory space usage
  15. free – Show memory and swap usage
  16.  
  17. Keyboard Shortcuts
  18.  
  19. Enter – Run the command
  20. Up Arrow – Show the previous command
  21. Ctrl + R – Allows you to type a part of the command you're looking for and finds it
  22.  
  23. Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background
  24. Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
  25. Ctrl + L – Clear the screen
  26.  
  27. command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
  28. !! – Repeats the last command
  29. command  !$ – Repeats the last argument of the previous command
  30. Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command
  31.  
  32. Ctrl + A – Return to the start of the command you're typing
  33. Ctrl + E – Go to the end of the command you're typing
  34. Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
  35. Ctrl + K – Cut everything after the cursor to a special clipboard
  36. Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
  37. Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
  38. Ctrl + W – Delete the word / argument left of the cursor in the current line
  39.  
  40. Ctrl + D – Log out of current session, similar to exit
  41.  
  42. Learn the Commands
  43.  
  44. apropos subject – List manual pages for subject
  45. man -k keyword – Display man pages containing keyword
  46. man command – Show the manual for command
  47. man -t man | ps2pdf - > man.pdf  – Make a pdf of a manual page
  48. which command – Show full path name of command
  49. time command – See how long a command takes
  50.  
  51. whereis app – Show possible locations of app
  52. which app – Show which app will be run by default; it shows the full path
  53.  
  54. Searching
  55.  
  56. grep pattern files – Search for pattern in files
  57. grep -r pattern dir – Search recursively for pattern in dir
  58. command | grep pattern – Search for pattern in the output of command
  59. locate file – Find all instances of file
  60. find / -name filename – Starting with the root directory, look for the file called filename
  61. find / -name ”*filename*” – Starting with the root directory, look for the file containing the string filename
  62. locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
  63. updatedb – Create or update the database of files on all file systems attached to the Linux root directory
  64. which filename – Show the subdirectory containing the executable file  called filename
  65. grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind
  66.  
  67. File Permissions
  68.  
  69. chmod octal file – Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4read (r), 2 – write (w), 1 – execute (x)
  70. Examples:
  71. chmod 777read, write, execute for all
  72. chmod 755 – rwx for owner, rx for group and world
  73. For more options, see man chmod.
  74.  
  75. File Commands
  76.  
  77. ls – Directory listing
  78. ls -l – List files in current directory using long format
  79. ls -laC – List all files in current directory in long format and display in columns
  80. ls -F – List files in current directory and indicate the file type
  81. ls -al – Formatted listing with hidden files
  82.  
  83. cd dir – Change directory to dir
  84. cd – Change to home
  85. mkdir dir – Create a directory dir
  86. pwd – Show current directory
  87.  
  88. rm name – Remove a file or directory called name
  89. rm -r dir – Delete directory dir
  90. rm -f file – Force remove file
  91. rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)
  92.  
  93. cp file1 file2 – Copy file1 to file2
  94. cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn't exist
  95. cp file /home/dirname – Copy the filename called file to the /home/dirname directory
  96.  
  97. mv file /home/dirname – Move the file called filename to the /home/dirname directory
  98. mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2
  99.  
  100. ln -s file link – Create symbolic link link to file
  101. touch file – Create or update file
  102. cat > file – Places standard input into file
  103. cat file – Display the file called file
  104.  
  105. more file – Display the file called file one page at a time, proceed to next page using the spacebar
  106. head file – Output the first 10 lines of file
  107. head -20 file – Display the first 20 lines of the file called file
  108. tail file – Output the last 10 lines of file
  109. tail -20 file – Display the last 20 lines of the file called file
  110. tail -f file – Output the contents of file as it grows, starting with the last 10 lines
  111.  
  112. Compression
  113.  
  114. tar cf file.tar files – Create a tar named file.tar containing files
  115. tar xf file.tar – Extract the files from file.tar
  116.  
  117. tar czf file.tar.gz files – Create a tar with Gzip compression
  118. tar xzf file.tar.gz – Extract a tar using Gzip
  119.  
  120. tar cjf file.tar.bz2 – Create a tar with Bzip2 compression
  121. tar xjf file.tar.bz2 – Extract a tar using Bzip2
  122.  
  123. gzip file – Compresses file and renames it to file.gz
  124. gzip -d file.gz – Decompresses file.gz back to file
  125.  
  126. Printing
  127.  
  128. /etc/rc.d/init.d/lpd start – Start the print daemon
  129. /etc/rc.d/init.d/lpd stop – Stop the print daemon
  130. /etc/rc.d/init.d/lpd status – Display status of the print daemon
  131. lpq – Display jobs in print queue
  132. lprm – Remove jobs from queue
  133. lpr – Print a file
  134. lpc – Printer control tool
  135. man subject | lpr – Print the manual page called subject as plain text
  136. man -t subject | lpr – Print the manual page called subject as Postscript output
  137. printtool – Start X printer setup interface
  138.  
  139. Network
  140.  
  141. ifconfig – List IP addresses for all devices on the local machine
  142. iwconfig – Used to set the parameters of the network interface which are specific to the wireless operation (for example: the frequency)
  143. iwlist – used to display some additional information from a wireless network interface that is not displayed by iwconfig
  144. ping host – Ping host and output results
  145. whois domain – Get whois information for domain
  146. dig domain – Get DNS information for domain
  147. dig -x host – Reverse lookup host
  148. wget file – Download file
  149. wget -c file – Continue a stopped download
  150.  
  151. SSH
  152.  
  153. ssh user@host – Connect to host as user
  154. ssh -p port user@host – Connect to host on port port as user
  155. ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login
  156.  
  157. User Administration
  158.  
  159. adduser accountname – Create a new user call accountname
  160. passwd accountname – Give accountname a new password
  161. su – Log in as superuser from current login
  162. exit – Stop being superuser and revert to normal user
  163.  
  164. Process Management
  165.  
  166. ps – Display your currently active processes
  167. top – Display all running processes
  168. kill pid – Kill process id pid
  169. killall proc – Kill all processes named proc (use with extreme caution)
  170. bg – Lists stopped or background jobs; resume a stopped job in the background
  171. fg – Brings the most recent job to foreground
  172. fg n – Brings job n to the foreground
  173.  
  174. Installation from source
  175.  
  176. ./configure
  177. make
  178. make install
  179. dpkg -i pkg.deb – install a DEB package (Debian / Ubuntu / Linux Mint)
  180. rpm -Uvh pkg.rpm – install a RPM package (Red Hat / Fedora)
  181.  
  182. Stopping & Starting
  183.  
  184. shutdown -h now – Shutdown the system now and do not reboot
  185. halt – Stop all processes - same as above
  186. shutdown -r 5 – Shutdown the system in 5 minutes and reboot
  187. shutdown -r now – Shutdown the system now and reboot
  188. reboot – Stop all processes and then reboot - same as above
  189. startx – Start the X system
RAW Paste Data