Basic commands

Here is a reminder of the basic Linux commands and actions we will frequently use on the Linux terminal.
Each command is validated with Enter.

Already familiar with Linux command line? Jump to the next page.

Login / logout

From a Windows command prompt, or from a MacOS or Linux terminal, remotely login with the user leguellec into the server howto.cogip.be using ssh:

TXT
ssh leguellec@howto.cogip.be

Logout:

TXT
exit

While logged in, temporarily switch to another user called berthier:

TXT
su - berthier

Update / upgrade

Collect the latest versions of installed software with apt update, install these collected updates with apt upgrade, accept by default the installation of upgrades with -y and chain the commands one after the other with &&:

TXT
sudo apt update && sudo apt upgrade -y

Reboot / shutdown

Immediately reboot the server:

TXT
sudo reboot

Immediately shutdown the server:

TXT
sudo shutdown -h now

Physical status

Visual tool to check physical health, memory status, load and services running:

TXT
htop

Check disk space used and available on the root directory /:

TXT
df -h /

Detailed check of disk space used by /home sub-directory:

TXT
sudo du -c -h -d 1 /home 2>/dev/null

Search for a file named filename.ext in /usr sub-directory, and only display any successful find

TXT
sudo find / -iname "*filename.ext*" 2>/dev/null

Nano file editor

  • Select text: move the cursor at the beginning of the section to select with keyboard arrows, use Alt+a and move the cursor at the end of the section
  • Cut text Ctrl+k
  • Paste text Ctrl+u
  • Undo Alt+u
  • Save file Ctrl+s
  • Quit nano Ctrl+x