Linux is most effectively controlled through the terminal, and a few dozen commands open the door to its full power. It is not hard, you just need to know the basics. Let us go through the most important Linux commands clearly and by group. If you are just starting, the article which Linux distribution to choose also helps.

Moving through the file system

CommandWhat it does
pwdprints which folder you are in
lslists the contents of a folder
ls -lalists everything including hidden files and details
cd foldergoes into a folder
cd ..one level up

Working with files and folders

CommandWhat it does
mkdir namecreates a folder
touch filecreates an empty file
cp source targetcopies a file
mv source targetmoves or renames
rm filedeletes a file
rm -r folderdeletes a folder with its contents

Be careful with rm, what is deleted does not go to a recycle bin.

Viewing file contents

CommandWhat it does
cat fileprints the whole content
less filepages through a long file
head / tailstart / end of a file
nano filea simple text editor in the terminal

Searching

CommandWhat it does
find . -name "*.txt"finds files by name
grep "text" filefinds text in a file
locate namequick search using a database

Permissions and rights

In Linux every file has rights to read, write and execute. These commands help:

CommandWhat it does
ls -lshows the rights (rwx)
chmodchanges a file’s rights
chownchanges the owner
sudo commandruns a command with administrator rights

System and processes

CommandWhat it does
top or htoprunning processes and load
ps auxlist of processes
kill PIDends a process
df -hfree space on disks
free -hmemory usage
uname -ainformation about the system

Installing software

The way depends on the distribution, because each family has its own package manager:

SystemExample of installation
Debian, Ubuntu, Mintsudo apt install name
Fedorasudo dnf install name
Archsudo pacman -S name

Before installing it is good to update the lists, for example sudo apt update.

Network commands

CommandWhat it does
ip ashows network addresses
ping addresstests reachability
ssh user@servera remote connection to a server
wget / curldownloads a file or calls an address

Useful tricks

  • Tab completes names, the up arrow recalls previous commands.
  • man command shows the manual for any command.
  • The pipe | joins commands, for example ls -la | grep ".txt".
  • history shows the command history.

Watch out for dangerous commands

Especially rm -rf in combination with sudo can irreversibly delete large parts of the system. Never run sudo rm -rf / and always check commands you copy from the internet. This relates to the article on the command line and terminal.

Do you need help with Linux or to deploy a server? Get in touch, we will advise and set it up. The article revive an old computer with Linux also comes in handy.