30 Linux Beginner Commands

$ su -
<root password>
$ visudo
root ALL=(ALL) ALL
<username> ALL=(ALL) ALL

  1. ls [-lahr]. List contents of current directory. [-l] to list information about files, folders. [-a] to list hidden ones. [-hr] to print file sizes in KB and MB instead of bytes.
  2. pwd. Print working directory
  3. cd <directory>. Change directory to <directory>.
  4. pushd <directory>. Change directory to <directory>, but revert to current on popd.
  5. popd. Change to previous directory saved by pushd.
  6. grep [-R] <pattern> <file>. Print lines matching <pattern> in <file>. [-R] to search in subdirectories recursively.
  7. sudo <command>. Perform <command> as super-user.
  8. su -[p]. Switch to super-user mode (ie. root). The [p] preserves current working directory amd does not cd to /root.
  9. lsof [<device>]. List open files on <device>.
  10. updatedb. Update the search database.
  11. locate <file/directory>. Locate files in / using the database created by updatedb.
  12. mv <source> <destination>, Move a <source> to <destination>. <source> and <destination> may also be directories. Can also be used to rename files.
  13. rm [-rf] <file/directory>. Remove <file/directory> forever. <directory> removed must be empty or [-r] must be specified. [-f] removes without confimation, especially useful when removing multiple files/directories.
  14. chmod <permissions> <file/directory>. Change permissions of <file/directory>. <permissions> may be specified as +/- r/w/x for enable/disable read/write/execute or simply a three digit number.
  15. mkdir <directory>. Makes <directory>
  16. man <command>. Displays the manual of command describing usage and features of the command. Also used to refer to programming manuals (eg. man stdio) if installed.
  17. ps [aux]. List processes along with process IDs. [aux] to list all.
  18. kill [-9] <processid>. Kill process specified by <processid>. [-9] is used to instruct the process to kill itself.
  19. killall <processname>. Kill all processes which have the name <processname>.
  20. date. Displays system date/ time. Can also be used to set date/ time. Read manual for more
  21. cal. Displays the month's calendar highlighting current day.
  22. finger. Get information about all users logged onto system.
  23. ping <ip>. Send test packets to <ip> to verify that the <ip> exists provided the system specified by <ip> responds to the ping.
  24. df. Print disk space free.
  25. du. Print disk space used.
  26. tar [xvf/cvf/-] [-C <directory>] <archive> [<directories to archive>]. Extract tarball into <directory>. [x] extracts and [c] creates archive. [-] extracts to stdout.
  27. unzip [-d <directory>] <zipfile>. Unzip zipfile into <directory>.
  28. rpm -qli <package>. Display information about <package>.
  29. rpm -qa <package>. Query all packages for <package>.
  30. basename <filename> [<suffix>]. Strip directory and <suffix> from <filename>. <filename> may be a fictitious file.
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.