Mozilla Skin

Command Line Activity

From Linux & Open Source @ NUS

This is a compilation of useful commands to know if you're ever stuck without a GUI, or are just curious :) It's probably best to learn them before you have to, yeah?


Getting your bearings:

  • whoami: whenever you get so nervous you forget what your login name is, this command will remind you.
  • pwd: could have been called whereami but this was shorter; shows your current directory.
  • ls: shows a list of the files and subdirectories in the current directory.
  • cd: changes back to your home directory, listed in $HOME.
  • cd directory: changes to the named directory.


Basic file operations:

  • rm filename: deletes the file called filename.
  • rm -rf /: something you should never do; removes all files in all directories! Read man rm for more details.
  • mv filename1 filename2: moves filename1 to a new location, filename2. Also serves as a quick rename function.
  • cp filename1 filename2: copies filename1 to a new location, filename2.


Finding things:

  • whereis filename: shows the location of a particular program or file.
  • locate filename: checks a database to find the named file.
  • # updatedb: updates the database of filenames which is used by locate. # means it should be done as root.
  • find location filename: looks for filename in location and its subdirectories.
  • grep regexp filename: looks for lines of text matching the regular expression regexp within filename.


Utility commands:

  • man command: consults the man(ual) pages for a command. Can be used for certain other files as well.
  • apropos: searches the manual pages for relevant commands, listing what you might have meant.
  • su: switches user. Allows you to log in as any other user, provided of course you know their password.
  • sudo command: executes command as a super user, or root, provided you have the permission.


Files and partitions:

  • df: checks the disks (mounted partitions) for free space.
  • du: shows the disk usage (filesize) of each file in the current directory.
  • mount: shows what disks (partitions) have been mounted and are accessible. When used as root, allows partitions to be mounted.
  • umount: unmounts a particular partition.