Utility terminal commands for Ubuntu

ps command

Use this command to get a list of currently running processes. Along with the list you get process related information.

ps

This would be returned for the current users processes whose effective user id (euid=EUID) is the same.

To get a more detailed output include the options “aux”, where a refers to all proccesses; u for user processes; x refers to system processes.

ps -aux

su command

To change user or become superuser.

// Changes user to root
su

You will be prompted root user password to switch to user.

// Change user to another user
su <user-name>

To change user back:

exit

wget command

Use this command to download files via terminal.

wget <file-url>

For example, you can download a tar file, here wget tar file:

wget http://ftp.gnu.org/gnu/wget/wget-1.13.tar.gz

history command

Use this command to get a list of command that you had executed through terminal earlier.

history

To remove(clear) the history:

history -c

The above command will remove all commands from the history list.

tar command

To archive or extract a file or directory.

tar [option] <file-name>

or 

tar [option] <directory-name>

To create a archive named “zip.tar” with a file “file.txt” in current directory.

tar -cvf zip.tar file.txt

To create a archive named “zip.tar” with all the files in the current directory, you can use:

tar -cvf zip.tar *

Extract a tar file

To extract a file named “zip.tar”, you can do the following:

tar -xvf zip.tar

This would extract all the files into the current directory.

mount command

To mount disk drives manully. (In ubuntu server automount doesnt happen, so if need to mount a drive you can use this command).

To check the drive properties use:

sudo fdisk -l

The above command will give you a list of drives. Find your drive’s name(1st column eg. “/dev/sda2”) and its device type(last column eg. “NTFS”).

Create the mount point:

mkdir /mount/<mount-point-name>

Now you can mount the drive using mount point created above. Say, if you have a “NTFS” drive with drive name as /dev/sda2, then to mount that drive you can do:

sudo mount -t ntfs /dev/sdb2 /media/<mount-point-name>

unmount command

To unmount a mounted drive manually.

sudo unmount <device-name>

or 

sudo unmount /media/<mount-point-name>