Basic Linux BASH commands

Shell prompts:

  • $ - Means you are a user. From the terminal you will see:
  • user@host:~$
  • # - Means you are root (superuser). From the terminal you will see:
  • user@host:~#

Permitting administrative tasks:

  • sudo - Within Ubuntu, gives administrative privileges, e.g:
  • sudo mkdir /some-directory
  • su - Within Debian, gives administrative privileges, e.g:
  • su mkdir /some-directory

Directories and files:

  • cd - Changes the directory you are in, e.g. to go to the mnt directory:
  • cd /mnt
  • cd .. - Moves you up one directory, e.g. from /home/user to /home:
  • cd ..
  • ~ - Move to the users home directory:
  • ~
  • ls - Lists the directory contents (minimal):
  • ls
  • ls -laF - Lists the directory contents (detailed):
  • ls -laF
  • mkdir - Creates a directory, e.g:
  • mkdir some-directory
  • Note: you cannot use spaces when creating directories
  • rm - Removes (deletes) a file, e.g:
  • rm some-file
  • rm -r - Removes (deletes) a directory and its contents, e.g:
  • rm -r some-directory
  • rmdir - Removes (deletes) an empty directory, e.g:
  • rmdir some-directory

Mounting drives:

  • mount - Mounts a drive, e.g:
  • mount /dev/hd-drive /mnt/hd-drive
  • To auto mount the drive on boot you need to edit fstab:
  • vi /etc/fstab
  • then add a new line in the file:
  • /dev/hd-drive /mnt/hd-drive ext3 defaults 0 0
  • Note: the options (ext3 defaults 0 0) above may vary depending on the drive being mounted

Editing with gedit:

  • gedit - Opens the gedit text editor from the terminal, e.g:
  • gedit /some-directory/some-file
  • Note: add sudo / su for root permissions

Miscellaneous:

  • shutdown -r now - shuts down the system, then reboots
  • shutdown -h now - shuts down the system and leaves it off (halts)
  • fdisk -l - shows hard disk and partition information
  • Ctrl + h - within Ubuntu, shows all hidden files

Go back to the How-to Guides main page.

Web accessibility:

A A A A

For more information about these functions and how to use them, view the web accessibility page.


Valid XHTML 1.0 Strict

Valid CSS!