Using the Linux Terminal

When using a Linux operating system, you can type various commands on the command prompt in the terminal window to perform different operations.

linux terminal

Understanding the most basic Linux commands will allow you to navigate directories, mount drives, copy files, change permissions, administer users, and so on. We’ll take a look at these commands in this section.

Listing Files and Directories

lsList files and directories
ls -aList all files and directories
ls -lDetailed list of  files and directories
mkdir <dir-name>Create directory
cd <dir-name>Change to directory
cd /Change to root directory
cd ~Change to home-directory
cd ..Change to parent directory
find <name>Find file <name>  (use *)
pwdDisplay the path of the current dir

Working with Files

cp <file> <destination>Copy file to destination
mv <file> <destination>Move file to destination
rm <file>Delete file
rmdir <dir>Delete directory
rm <dir>Delete directory
rm -rf <dir>Delete directory and its contents
more <file>Displays file a page at a time
head <file>Displays first few lines of file
tail <file>Displays last few lines of file
grep ‘keyword’ <file>Search file for keyword
zip -r <archive> *Zip files & folders in current directory
zip <archive-name> <files>Compress files into zip archive
unzip <file-name>Uncompress zipped file
nano <file-name>Text editor
treeDisplay directory tree

File Permissions

chmod [options] <file>Change access rights for a file or directory  
Options: user, group, other
Eg: chmod 744
4 stands for “read”,
2 stands for “write”,
1 stands for “execute”, and
0 stands for “no permission.”
User: 7 (4+2+1)  (read, write, execute)
Group: 4 (read)
Other: 4 (read)
sudo chown <user> <file>Change file/dir ownership


sudo <command>Execute command with root privileges
su <username>Switch user
sudo useradd <username>Add new user
sudo groupadd <groupname>Add new user group
sudo usermod -g <group> <user>Change user’s group
sudo passwd <username>Change password of user
whoamiShow user currently logged in


netstatDisplays network state
ping <hostname>Check host is online
sftp [user-name]@[server]Secure ftp connection to server
hostnameDisplay hostname or machine name
ssh [user-name]@[server]Open a SSH connection to server


sudo shutdown  – –poweroffShow down machine
sudo rebootReboot machine
man <command>Get manual page on command
sudo mount <dev> <dir>Mount device
Eg: sudo mount /dev/sda2  ~/media
wget <package-url>Download and install package
clearClear terminal window
lsblkShow devices connected to your system
sudo parted /dev/<drive>Partition drive (sda)  
mkpart primary ext4 1MiB <size>
type print to display all partitions
rm <partition> to delete partition
sudo mkfs.ext4  /dev/<partition>Create file system on partition

Return to resources