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 grav.howto.ovh using ssh:

ssh leguellec@grav.howto.ovh

Logout:

exit

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

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 &&:

sudo apt update && sudo apt upgrade -y

Reboot / shutdown

Immediately reboot the server:

sudo reboot

Immediately shutdown the server:

sudo shutdown -h now

Physical status

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

htop

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

df -h /

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

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

result=$(find /usr -name "filename.ext" 2>/dev/null)
if [ -n "$result" ]; then
    echo "$result"
fi

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