Skip to main content
You can use command --help or man command for more information about any command.

pwd

pwd stands for print working directory. It displays the absolute path of the directory you are currently in.
kc@kcserver:~$ pwd
/home/kc

cd

cd stands for change directory. It is used to navigate between directories.
An absolute path starts from the root directory /, while a relative path is relative to the current working directory.
karchunt@kcserver:~/folder3$ cd ..
karchunt@kcserver:~$

ls

ls lists the files and directories in the current directory or a specified directory.
karchunt@kcserver:~$ ls
folder1  folder2  newfile.txt

karchunt@kcserver:~$ ls folder1
newname.txt
Useful ls options:
OptionDescription
-lLong listing format with detailed info
-aShow all files, including hidden files (. prefix)
-hHuman-readable file sizes (KB, MB, etc.)
-tSort by modification time, newest first
-rReverse the sort order
Combining options:
karchunt@DESKTOP-CCAQ09F:~$ ls -lahtr
total 68K
drwxr-xr-x 3 root     root     4.0K Nov  1 17:37 ..
-rw-r--r-- 1 karchunt karchunt  807 Nov  1 17:37 .profile
-rw-r--r-- 1 karchunt karchunt 3.7K Nov  1 17:37 .bashrc
-rw-r--r-- 1 karchunt karchunt  220 Nov  1 17:37 .bash_logout
drwx------ 2 karchunt karchunt 4.0K Nov  1 17:38 .cache
...

Creating Files and Directories

mkdir

mkdir creates a new directory.
karchunt@kcserver:~$ mkdir folder1 folder2
karchunt@kcserver:~$ ls
folder1  folder2
If the parent directory does not exist, use the -p flag to create all necessary parent directories:
karchunt@kcserver:~$ mkdir folder3/innerfolder
mkdir: cannot create directory 'folder3/innerfolder': No such file or directory

karchunt@kcserver:~$ mkdir -p folder3/innerfolder
karchunt@kcserver:~$ ls folder3
innerfolder

touch

touch creates an empty file.
karchunt@kcserver:~$ touch newfile.txt
karchunt@kcserver:~$ ls
newfile.txt

Moving and Copying

mv

mv moves or renames files and directories.
karchunt@kcserver:~$ mv oldname.txt newname.txt
karchunt@kcserver:~$ ls
newname.txt

cp

cp copies files and directories.
karchunt@kcserver:~$ cp folder1/newname.txt folder2/
karchunt@kcserver:~$ ls folder2
newname.txt

Removing Files and Directories

rm

rm removes files and directories.
Be very careful with sudo rm -rf. It force-deletes folders with superuser privileges and can permanently destroy important system files if used incorrectly. There is no recycle bin — deletion is immediate and irreversible.
karchunt@kcserver:~$ rm folder2/newname.txt
karchunt@kcserver:~$ ls folder2
karchunt@kcserver:~$

Viewing File Contents

cat

cat can view file contents, create new files, or concatenate multiple files.
karchunt@kcserver:~$ cat folder1/newname.txt
This is a sample text file.

more

more views file contents one screen at a time.
karchunt@kcserver:~$ more largefile.txt
This is line 1
This is line 2
Key controls:
KeyAction
SpaceNext page
EnterNext line
bPrevious page
/ + termSearch within the file
qQuit

less

less is similar to more but with more advanced navigation features.
karchunt@kcserver:~$ less largefile.txt
This is line 1
This is line 2
Key controls:
KeyAction
SpaceNext page
bPrevious page
Enter / Next line
Previous line
/ + termSearch within the file
qQuit
Prefer less over more for large files — it loads faster and allows both forward and backward navigation.

Other Useful Commands

echo

echo displays a line of text or the value of a variable.
kc@kcserver:~$ echo "Hello World"
Hello World

kc@kcserver:~$ echo -n "Hello World" # without trailing newline
Hello Worldkc@kcserver:~$

uptime

uptime shows how long the system has been running, along with the current time, number of logged-in users, and system load averages.
kc@kcserver:~$ uptime
 14:23:58 up 7 min,  2 users,  load average: 0.04, 0.03, 0.00

Build docs developers (and LLMs) love