Ubuntu 10.04 Linux Commands Cheat Sheet

Unzip:

  • sudo apt-get install unzip
  • unzip [file]

Tar:

  • tar -cvvf foo.tar [directory]
  •  tar -zcvf {new file name}.tar.gz {directory to compress}

Untar:

  • tar -zxvf yourfile.tar
  • tar -xvfz filename.tar.gz
  • tar -xvzf filename.tar.gz [directory]
  • tar -jxvf filename.tar.bz2

Find: find [dir] -type d|f -iname ‘searchstring’

  • find / -type -d -iname ‘python’
  • find ~ -type d -exec chmod +x {} ;

Delete a user account

  • sudo deluser <username>

Add an New user

  • sudo useradd <username>

or

  • sudo useradd -d /home/<directory> -m <username>

( -d specifies home directory, -m makes the folder if it doesn’t exist )

useradd doesn’t add password unless you add -p     …. or you can just set the password later with:

  • sudo passwd <username>

If called with two non-option arguments (see below), adduser will add an existing user to an existing group.

Add an existing user to an existing group

  • sudo usermod -a -G <group> <user>

Set password of new user

  • sudo passwd <username>

Make a new Group: 

  • groupadd <groupname>

To see what groups currently exist:

  • cat /etc/group

To see current users logged in:

  • w

Count lines in file:

  • wc -l <filename>