Linux Basics#

Linux is the basis of a lot of different operating systems. Many companies and developers release their own versions of linux called distributions or distros. The biggest companies being RedHat (RedHat Enterprise Linux) and Canonical (Ubuntu). We at EODC offer some of those distros to use in our Openstack environments.

Linux basics cheat sheet#

Basic commands#

Some symbols have special meanings in the terminal:

  • / refers to the root directory

  • . refers to your current working directory

  • ~ refers to the current users home directory

Command

What it does

Navigate the filesystem

ls

Lists the files in your current working directory

cd <path or directory>

Move through the file system using either relative or absolute paths. cd .. to go up one directory

pwd

Prints your current working directory

File manipulation

cp <src> <dest>

Copies files or directories

mv <src> <dest>

Moves files or directories

rm [-r] <file or directory>

Deletes files (add -r to delete recursively)

cat <filename>

Print out the contents of a file

less <filename>

Prints out the contents of a file but with the ability to scroll and search by typing /. Quit with q

nano <filename>

Is a basic and easy to use text editor

mkdir <directoryname>

Creates a new directory

touch <filename>

Creates a new empty file

Miscellaneous

sudo <command>

Gives the user admin privileges for the command

man <command>

Opens a manual for the given command

history

Prints previously entered commands

Managing packages#

Different distros use different tools to manage packages called package managers.\n I will use nano as an example package:\n Nano is a popular and very easy to use terminal text editor.\n Other examples would be Vim or Emacs but those aren’t as beginner friendly\n Debian and distros based on it use apt:

sudo apt update && sudo apt upgrade     # updates the system
apt search nano                         # search for nano in repositories
sudo apt install nano                   # installs nano
sudo apt remove nano                    # to remove the package

RedHat based distros like Almalinux use dnf:

sudo dnf update         # updates the system
dnf search nano         # search for nano in the repositories
sudo dnf install nano   # installs nano
sudo dnf remove nano    # to remove the package