Or press ESC to close.

Linux: How to use basic commands [Part 1]

19 September 2025 20:40 Computer

If you're learning Linux, get familiar with these four commands:

ls
cd
cd ..
pwd

ls allows you to list the files in a directory.

cd followed by the name of a directory, makes you go into that directory.
cd used alone makes you go to your home directory.

cd .. makes you go into the parent directory.

pwd shows you where you are.

Those are, for me, the most important commands.


Basic commands:

                

cd to change directory

cd - to go back to the previous directory

cd .. to go to the parent directory

cd ./ using relative pathname ( "./" is the current directory)

pwd to print working directory (shows where you are)

ls to list the files

ls /* to list the files in another directory

ls -l long format

ls -lt long format + sort results by the file's modification time

ls -lt --reverse like ls -lt but in reverse

ls -a --all lists all files, even hidden

ls -A --almost all like -a except . and .. (current directory and parent directory)

ls -d --directory to see detail about directory (not the content)

ls -F --classify appends an indicator at the end of name

ls -h --human-readable display size in human readable format

ls -r --reverse display result in reverse order (instead of alphabetical)

ls -s sort results by file size

ls -t sort by modification time

ls -li show inode for hard links

file "filename" file description

less "filename" examine textfile

/characters search forward for "characters"

n search for the next occurence of previous search

h display help screen

G move to the end of the text file

g move to beginning

cp copy files and directories

-a also copy attributes, like ownerships and permissions

-i prompt before overwritting existing file

-r recursively copy directories and their contents

-u updates files or copy files that dont exist already

-v verbose, displays information while copying

mv move/rename files and directories

-i prompts before overwriting an exising file

-u updates files

-v verbose, displays information

mkdir create directories

mkdir dir1 dir2 dir3

rmdir delete directories

rmdir dir1 dir2 dir3

rm remove files and directories (trick: use ls first)

-i prompts for confirmation

-r recursive, every directories in it

-f force

-v verbose, displays information

ln Create hard and symbolic links

-s symbolic link (ex: ln -s fun fun-sym /or/ ln -s ../fun dir1/fun-sym)

Wildcards :

* Matches any characters

? Matches any single character

[characters] Matches any character that is a member of the set characters

[!characters] Matches any character that is not a member of the set characters

[[:class:]] Matches any character that is a member of the special class

[:alnum:] alphanumeric character

[:alpha:] alphabetic character

[:digit:] numeral

[:lower:] lowercase letter

[:upper:] uppercase letter

Most of my studying of Linux was done using the book: The Linux Command Line by William Shotts, while daily driving Arch Linux.

I highly recommend the book for anyone wanting to learn Linux.

Hedi0410

based in France.