New User Tutorial: Basic Shell Commands

Linux and all version of unix (including MacOS) have a very rich command line that can be used in many different ways to form very powerful commands. These commands can be joined together to do complex jobs in a very simple way. These are some of the basic commands to get you started.

ls – List Directory Contents

List files in the current directory
ls -l
Display directory contents in a “long list” format.
ls -lah
Display all files, including hidden, with a human-readable file size.

cd – Change Directories

cd /var/log
Changes location to /var/log
cd ~
Changes to your user’s home directory.
cd –
Returns you to the previous directory you were working in.
cd ..
Moves you one directory up/back in the directory structure.

cp – Copy a File

The cp command copies a file from one place to another, or can create a new copy of a file in the same location with a different name.

cp file.txt newfile.txt
Copy file.txt to newfile.txt
cp -r /home/user/pics /home/user2/
Recursively (meaning the directory and all of its contents) copy the pics directory from /home/user/ to /home/user2/

mv – Move and Rename Files

mv file.txt /home/user/newuser/
Moves the file called file.txt to the directory /home/user/newuser/
mv oldfile.txt newfile.txt
Renames the file oldfile.txt to newfile.txt

mkdir - Make Directory

mkdir files
Makes a new directory called files

rm – Remove a File (Delete)

rm file.txt
Deletes the file called file.txt
rm -r files
Deletes the directory called files along with everything in it

rmdir - Remove Directory (Delete)

rmdir files
Deletes an empty directory called files

cat – Display File Contents

cat file.txt
Displays the entire contents of the file file.txt

locate - Locate a file

The locate - a.k.a. find - command is meant to find a file within the filesystem. If you don't know the name of a certain file or you aren't sure where the file is saved and stored, the locate command comes in handy.

locate -i filename
Searches the filesystem for filename ignoring case


ping - send a packet of data to another network device and time the reply

Sends a packet to (Google's public DNS server) and waits for the reply


Get instructions for a particular command

man man
Get help with the man command 
man ls
Get help on ls 

w – List Active System Users

Displays a list of users who are logged in to the system through a remote shell or local terminal, what they are doing, and other relevant information.



Tux is a penguin character and the official mascot of the Linux kernel. Tux is the most commonly used icon for Linux, although different Linux distributions depict Tux in various styles. The character is used in many other Linux programs and as a general symbol of Linux.