Thu 11/6/25, 8:03 PM | CS

Using Linux on the Command Line: Basic Commands

This is a list of the basic commands that are available when you use Linux on the command line interface - for example, in a virtual terminal or a terminal window (terminal emulator). This guide is written for the bash shell. When you launch a terminal window, you often get the bash shell, but this depends on your system and its settings.

How to List the Files in a Directory

List files in the current directory

ls

Print directory listing with details:

ls -l

Print directory listing with hidden files (files beginning with a dot):

ls -a

Print directory listing using "human-readable" file sizes:

ls -lh

How to Display and Change the Current Directory

Show what the current directory (present working directory) is:

pwd

Change current directory to "dir2"

cd dir2

Change to parent directory

cd ..

Change to root directory

cd /

Change to your home directory

cd

How to Edit or Display Files

Edit file notes.txt (if the nano editor is installed):

nano notes.txt

Print file notes.txt on terminal

cat notes.txt

View file contents so that you can scroll the contents using arrow keys (press q to quit the reader):

less notes.txt

How to Copy, Rename, Move, or Delete Files

Copy file notes.txt to notes2.txt

cp notes.txt notes2.txt

Rename file notes.txt to oldnotes.txt

mv notes.txt oldnotes.txt

Move file oldnotes.txt from current directory to /home/mydir (assuming /home/mydir is an existing directory where you have write access):

mv oldnotes.txt /home/mydir

Move file oldnotes.txt to parent directory

mv oldnotes.txt ../

Delete (remove) file oldnotes.txt

rm oldnotes.txt

Delete the directory called abc (assuming it is empty):

rmdir abc

How to Log Out

To log out, press Ctrl+D or type

logout

How to Get the Manual of a Command

Many commands have a manual page, also called the "man page". You can access it by typing "man" followed by the name of the command. For example, to open the man page of the command ls:

man ls
ls --help

Adding a parameter "--help" to a command is another way to ask for instructions. For example:

If the command is a "built-in command" (internal command of the bash shell), type "help" followed by the command. For example:

help for
Click anywhere to close