Some basic Terminal commands for ubuntu linux

What is sudo? – It stands for Super User DO and is a command that allows users to have root/super user access without logging as a root

APT-GET Commands

The apt-get is a very powerful command-line tool commonly used for updating the software sources (repositories) , upgrading existing installed software, installation and removal of new software. lets look at some common apt-get commands.

Updating and Upgrading software

This is a very common apt command that is used to update your software sources. It is the first command that you enter when you have installed a fresh ubuntu.

sudo apt-get update

upgrade command downloads and installs any newer versions of your installed software. make sure you run the above update command first so that the software sources are first updated and you get latest software.

sudo apt-get upgrade

Installing/Removing software

This command first downloads and then installs a new software. here we are installing a software called virtualbox. replace virtualbox with any other software you want to install. 

sudo apt-get install virtualbox

Now, to remove an existing software

sudo apt-get remove virtualbox

List all files/dirctories

The ls command lists all files and directories


If you want to see a long listing (detailed) use -l option

ls -l

The -a option will list all files including hidden files

ls -a

Creating a new file and folder

The touch command creates a empty new file

touch newfile

The mkdir command creates a new empty directory

mkdir newfolder

Add contents to a file

use the cat command with redirection ‘>’ to add text to a file. Press Ctrl+D when you have finished adding text.

cat > myfile

View Contents of a file
use the cat command to view contents of an existing file. let’s view myfile , that we created in the previous command

cat  myfile

Change Directory
with cd command you change your directory. by default you are in home directory. Let’s change our directory to Desktop

cd Desktop

Note: linux is case sensitive so don’t type ‘deskop’ but ‘Desktop’.

To come back to your previous directory(home directory)

cd ..

the double dot means the parent directory


just the cd command will take you to your home directory from wherever you are.


Present working Directory
the pwd command shows your current directory with full path name


Delete a file
‘rm’ stands for Remove and this will Delete the file myfile Permanently so you won’t be able to Restore it from Trash.

rm myfile

Copy a file
To copy files, you use the cp command. The following will copy file from home folder and paste it to Desktop.
By default you will be at your Home folder so you don’t need to change the directory.

sudo cp abc Desktop

Move a file

to move a file to different location, you use the mv command.The following command will cut file from Home folder and paste it to Desktop

sudo mv abc Desktop


Info Commands

Software versions:

lsb_release -a β€“ Distribution info
cat /etc/issue β€“ current distribution and version
apt-cache showpkg packagename β€“ packagename’s version and dependencies
uname -r – Linux kernel version
uname -a β€“ all kernel details

Graphics card:
glxinfo β€“ details about OpenGL, the Xserver, and your graphics card
glxinfo | grep direct β€“ It will show if you have direct 3d rendering or not
glxinfo | grep vendor β€“ graphics card vendor
lspci | grep VGA β€“ specific graphics card model
glxgears β€“ a simple 3d benchmark, prints frame rate to the terminal
xrandr β€“ supported display resolutions


lspci | grep Audio β€“ audio controller
aplay –list-devices β€“ more audio device information

lspci | grep Ethernet β€“ Ethernet controllers
ifconfig β€“ networking interfaces, IP addresses, and more


cat /proc/cpuinfo β€“ all processors, clock speeds, flags, and more
cat /proc/loadavg β€“ processor load average for the last 1, 5, and 15 minutes
top β€“ press C key to sort processes by CPU usage

cat /proc/meminfo β€“ amount of RAM and swap, and how much is being used for what
free -m β€“ total, used, and free memory shown in MB
top β€“ press M key to sort processes by memory usage

Hard disks:

df -H β€“ partitions, as well as their mount-points and usage in GB
sudo fdisk -l β€“ all partitions, their device names, and positions on disk

USB devices:

lsusb β€“ USB buses and attached devices

Even more:

lshal -m β€“ monitor for hardware changes
lspci β€“ all PCI devices
hwinfo –short β€“ overview of all hardware, as well as more detailed info
lshw β€“ another program for listing hardware
lshw -html | w3m -T text/html β€“ lists hardware with HTML output in the w3m web browser
uptime β€“ current time elapsed since last reboot, users, and load average

Leave a Reply

Your email address will not be published.