MightyPork

commands

Mar 21st, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.54 KB | None | 0 0
  1. 1. SYSTEM
  2.  
  3. # uname –a => Display linux system information
  4. # uname –r => Display kernel release information
  5. # cat /etc/redhat_release => Show which version of redhat installed
  6. # uptime => Show how long system running + load
  7. # hostname => Show system host name
  8. # hostname -i => Display the IP address of the host
  9. # last reboot => Show system reboot history
  10. # date => Show the current date and time
  11. # cal => Show this month calendar
  12. # w => Display who is online
  13. # whoami => Who you are logged in as
  14. # finger user => Display information about user
  15.  
  16.  
  17. 2. HARDWARE
  18.  
  19. # dmesg => Detected hardware and boot messages
  20. # cat /proc/cpuinfo => CPU model
  21. # cat /proc/meminfo => Hardware memory
  22. # cat /proc/interrupts => Lists the number of interrupts per CPU per I/O device
  23. # lshw => Displays information on hardware configuration of the system
  24. # lsblk => Displays block device related information in Linux (sudo yum install util-linux-ng)
  25. # free -m => Used and free memory (-m for MB)
  26. # lspci -tv => Show PCI devices (very useful to find vendor ids)
  27. # lsusb -tv => Show USB devices
  28. # lshal => Show a list of all devices with their properties
  29. # dmidecode => Show hardware info from the BIOS (vendor details)
  30. # hdparm -i /dev/sda # Show info about disk sda
  31. # hdparm -tT /dev/sda # Do a read speed test on disk sda
  32. # badblocks -s /dev/sda # Test for unreadable blocks on disk sda
  33.  
  34.  
  35. 3. STATISTICS
  36.  
  37. # top => Display and update the top cpu processes
  38. # mpstat 1 => Display processors related statistics
  39. # vmstat 2 => Display virtual memory statistics (very useful performance tool)
  40. # iostat 2 => Display I/O statistics (2sec Intervals)
  41. # tail -n 500 /var/log/messages => Last 10 kernel/syslog messages
  42. # tcpdump -i eth1 => Capture all packets flows on interface eth1 (useful to sort network issue)
  43. # tcpdump -i eth0 'port 80' => Monitor all traffic on port 80 ( HTTP )
  44. # lsof => List all open files belonging to all active processes.(sysadmin favorite command)
  45. # lsof -u testuser => List files opened by specific user
  46. # free –m => Show amount of RAM (daily usage command)
  47. # watch df –h => Watch changeable data continuously (interesting linux command)
  48.  
  49.  
  50. 4. USERS
  51.  
  52. # id => Show the active user id with login and group
  53. # last => Show last logins on the system
  54. # who => Show who is logged on the system (real user who logged in)
  55. # groupadd admin => Add group "admin" (force add existing group)
  56. # useradd -c "Sam Tomshi" -g admin -m sam => Create user "sam" and add to group "admin"
  57. # userdel sam => Delete user sam
  58. # adduser sam => Add user "sam"
  59. # usermod => Modify user information
  60.  
  61.  
  62. 5. FILE COMMANDS
  63.  
  64. # ls –al => Display all information about files/ directories
  65. # pwd => Show current directory path (simple but need every day)
  66. # mkdir directory-name => Create a directory
  67. # rm file-name => Delete file (be careful of using rm command)
  68. # rm -r directory-name => Delete directory recursively
  69. # rm -f file-name => Forcefully remove file
  70. # rm -rf directory-name => Forcefully remove directory recursively
  71. # cp file1 file2 => Copy file1 to file2
  72. # cp -r dir1 dir2 => Copy dir1 to dir2, create dir2 if it doesn’t exist
  73. # mv file1 file2 => Move files from one place to another
  74. # ln –s /path/to/file-name link-name => Create symbolic link to file-name
  75. # touch file => Create or update file (timestamp change)
  76. # cat > file => Place standard input into file (15 cat command examples)
  77. # more file => Output the contents of file (help display long tail files)
  78. # head file => Output the first 10 lines of file (with different parameters)
  79. # tail file => Output the last 10 lines of file (detailed article with tail options)
  80. # tail -f file => Output the contents of file as it grows starting with the last 10 lines
  81. # gpg -c file => Encrypt file (how to use gpg)
  82. # gpg file.gpg => Decrypt file
  83.  
  84.  
  85. 6. PROCESS RELATED
  86.  
  87. # ps # Display your currently active processes (many parameters to learn)
  88. # ps aux | grep 'telnet' # Find all process id related to telnet process
  89. # pmap # Memory map of process (kernel,user memory etc)
  90. # top # Display all running processes (30 examples)
  91. # kill pid # Kill process with mentioned pid id (types of signals)
  92. # killall proc # Kill all processes named proc
  93. # pkill processname # Send signal to a process with its name
  94. # bg # Lists stopped or background jobs (bg and fg command)
  95. # fg # Brings the most recent job to foreground
  96. # fg n # Brings job n to the foreground
  97.  
  98.  
  99. 7. FILE PERMISSION RELATED
  100.  
  101. # chmod octal file-name # Change the permissions of file to octal, which can be found separately for user, group and world
  102. octal value
  103. 4 - read
  104. 2 – write
  105. 1 – execute
  106.  
  107. Example
  108. # chmod 777 /data/test.c # Set rwx permission for owner , rwx permission for group, rwx permission for world
  109. # chmod 755 /data/test.c # Set rwx permission for owner,rw for group and world
  110. # chown owner-user file # Change owner of the file (chown more examples)
  111. # chown owner-user:owner-group file-name # Change owner and group owner of the file
  112. # chown owner-user:owner-group directory # Change owner and group owner of the directory
  113.  
  114. Example
  115. # chown bobbin:linoxide test.txt
  116. # ls -l test.txt
  117. -rw-r--r-- 1 bobbin linoxide 0 Mar 04 08:56 test.txt
  118.  
  119.  
  120. 8. NETWORK
  121.  
  122. # ifconfig –a # Display all network ports and ip address (set mtu and other all options)
  123. # ifconfig eth0 # Display specific ethernet port ip address and details
  124. # ethtool eth0 # Linux tool to show ethernet status (set full duplex , pause parameter)
  125. # mii-tool eth0 # Linux tool to show ethernet status (more or like ethtool)
  126. # ping host # Send echo request to test connection (learn sing enhanced ping tool)
  127. # whois domain # Get who is information for domain
  128. # dig domain # Get DNS information for domain (screenshots with other available parameters)
  129. # dig -x host # Reverse lookup host
  130. # host google.com # Lookup DNS ip address for the name (8 examples of host command)
  131. # hostname –i # Lookup local ip address (set hostname too)
  132. # wget file # Download file (very useful other option)
  133. # netstat -tupl # List active connections to / from system (13 examples)
  134.  
  135.  
  136. 9. COMPRESSION / ARCHIVES
  137.  
  138. # tar cf home.tar home # Create tar named home.tar containing home/ (11 tar examples)
  139. # tar xf file.tar # Extract the files from file.tar
  140. # tar czf file.tar.gz files # Create a tar with gzip compression
  141. # gzip file # Compress file and renames it to file.gz (untar gzip file)
  142.  
  143.  
  144. 10. INSTALL PACKAGE
  145.  
  146. # rpm -i pkgname.rpm # Install rpm based package (Installing, Uninstalling, Updating, Querying ,Verifying)
  147. # rpm -e pkgname # Remove package
  148.  
  149. Install from source
  150. ./configure
  151. make
  152. make install (what it is)
  153.  
  154.  
  155. 11. SEARCH
  156.  
  157. # grep pattern files # Search for pattern in files (you will this command often)
  158. #grep -r pattern dir # Search recursively for pattern in dir
  159. # locate file # Find all instances of file
  160. # find /home/tom -name 'index*' # Find files names that start with "index"(10 find examples)
  161. # find /home -size +10000k # Find files larger than 10000k in /home
  162.  
  163.  
  164. 12. LOGIN (SSH AND TELNET)
  165.  
  166. # ssh user@host # Connect to host as user (secure data communication command)
  167. # ssh -p port user@host # Connect to host using specific port
  168. # telnet host # Connect to the system using telnet port
  169.  
  170.  
  171. 13. FILE TRANSFER
  172.  
  173. scp
  174. # scp file.txt server2:/tmp # Secure copy file.txt to remote host /tmp folder
  175. # scp nixsavy@server2:/www/*.html /www/tmp # Copy *.html files from remote host to current system /www/tmp folder
  176. # scp -r nixsavy@server2:/www /www/tmp # Copy all files and folders recursively from remote server to the current system /www/tmp folder
  177. rsync
  178. # rsync -a /home/apps /backup/ # Synchronize source to destination
  179. # rsync -avz /home/apps [email protected]:/backup # Synchronize files/directories between the local and remote system with compression enabled
  180.  
  181.  
  182. 14. DISK USAGE
  183.  
  184. # df –h # Show free space on mounted filesystems(commonly used command)
  185. # df -i # Show free inodes on mounted filesystems
  186. # fdisk -l # Show disks partitions sizes and types(fdisk command output)
  187. # du -ah # Display disk usage in human readable form (command variations)
  188. # du -sh # Display total disk usage on the current directory
  189.  
  190.  
  191. 15. DIRECTORY TRAVERSE
  192.  
  193. # cd .. # To go up one level of the directory tree(simple & most needed)
  194. # cd # Go to $HOME directory
  195. # cd /test # Change to /test directory
  196.  
  197.  
  198. (Thanks to Linoxide.com, you can find the original page at http://linoxide.com/linux-command/linux-commands-cheat-sheet/)
Advertisement
Add Comment
Please, Sign In to add comment