# Linux (General) General topics relating to Linux and Unix operating systems # Basic Commands Overview
Command | Description | Package |
---|---|---|
`base64` | base64 encode/decode data and print to standard output | `coreutils` |
`basename` | strip directory and suffix from filenames | `coreutils` |
`cat` | concatenate — combine the output of files and print to standard output | `coreutils` |
`cd` | Change Directory — navigate directories on the filesystem | built-in |
`chmod` | change file mode bits (permissions) for files and directories | `coreutils` |
`chown` | change file owner and group | `coreutils` |
`clear` | clear the terminal content | `clear` |
`cp` | copy files | `coreutils` |
`csplit` | split a file into sections determined by context lines | `coreutils` |
`dd` | convert and copy a file | `coreutils` |
`df` | Disk Free — report overall file system space usage | `coreutils` |
`diff` | show differences between two files line by line | `diffutils` |
`dirname` | print the directory path if the passed file | `coreutils` |
`du` | Disk Usage — show file system usage for a given directory | `coreutils` |
`echo` | display a line of text | built-in |
`find` | search for files in a given directory | `findutils` |
`grep` | search for text | `grep` |
`head` | display the first X lines of a file (default 10) | `coreutils` |
`history` | print the history of issued commands | built-in |
`jobs` | display currently running jobs | built-in |
`kill` | terminate a process | `util-linux` |
`ls` | list directory contents | `coreutils` |
`man` | Manual — display the documentation of a given command | `man` |
`mkdir` | create a directory | `coreutils` |
`mv` | move (and rename) files | `coreutils` |
`ping` | check if a server is reachable | `iputils` |
`printenv` | print information about currently set environment variables | `coreutils` |
`printf` | format and print data | `coreutils` |
`pwd` | Print Working Directory — returns the current working directory | built-in |
`rm` | remove files and directories (caution: no undo!) | `coreutils` |
`scp` | OpenSSH secure file copy | `openssh` |
`sha256sum` | compute and check SHA256 message digest (variants for SHA1, SHA224, SHA384 and SHA512 exist) | `coreutils` |
`sort` | sort lines of text files | `coreutils` |
`sudo` | Super User Do — execute commands as root | `sudo` |
`tail` | display the last X lines of a file (default 10) | `coreutils` |
`tar` | archiving utility, compression optional | `tar` |
`top` | display Linux processes | `procps-ng` |
`touch` | create an empty file | `coreutils` |
`uname` | Unix Name — print system information | `coreutils` |
`unzip` | list, test and extract compressed files in a ZIP archive | `unzip` |
`useradd` | create a new user or update default new user information | `shadow` |
`userdel` | delete a user account and related files | `shadow` |
`wget` | download files from the internet | `wget` |
`zip` | package and compress (archive) files | `zip` |
Directory | Description |
---|---|
`/bin` | binary files of basic commands |
`/boot` | static files of the bootloader |
`/dev` | device files |
`/etc` | host-specific system configuration |
`/lib` | basic dynamic libraries and kernel modules |
`/media` | mount point for removable media |
`/mnt` | for temporarily mounted file system |
`/opt` | additional application programs |
`/run` | relevant data for running processes |
`/sbin` | essential binary files of the system |
`/srv` | data for services |
`/tmp` | temporary files |
`/usr` | secondary hierarchy |
`/var` | variable data |
**NOTE:** On most modern Linux distributions, `/bin` is actually a symbolic link pointing to `/usr/bin`.
The `/bin` directory contains essential binary files that are required for the system to function properly. These files are used by all users of the system, and they include basic system commands such as `ls`, `cp`, and `mv`. The `/bin` directory must not contain any subdirectories. Each installed package places its main executables here. ## `/boot` Directory The `/boot` directory contains the files needed by the bootloader for the Linux kernel, including the kernel itself, initrd (**init**ial **R**AM **d**isk), and boot loader configuration files. The bootloader is the program that loads the operating system when the computer starts up. The files in `/boot` are essential for the bootloader to function properly. ## `/dev` Directory The `/dev` directory contains device files that represent hardware devices connected to the system. These files allow applications and users to interact with the hardware devices such as keyboards, mice, and disk drives using standard input/output operations. There's different types of device files:Type | Description |
---|---|
Character device | Communication with a character device is based on the exchange of characters, such as individual bytes |
Block device | Communication with a block device is based on the exchange of entire blocks of data |
Pseudo device | Devices that are not corresponding to any real hardware actually present on the system |
File | Description |
---|---|
`/dev/dm-X` | Logical volumes created using LVM (**d**evice **m**anager). - X = index of device manager volume |
`/dev/hdX` | IDE hard drives or other storage devices. Common in older systems. - X = lower-case letter indicating order of discovery |
`/dev/hdXY` | Partitions on IDE storage device. - X = disk - Y = partition on that disk |
`/dev/jsX` | Device file for a joystick/gamepad. - X = index of a joystick connected to the system |
`/dev/mdX` | Software RAID devices (**m**eta **d**isk). - X = meta disk group index |
`/dev/mmcblkX` | MMC/SD cards and eMMC storage devices. - X = index of an MMC storage device |
`/dev/nvmeXnY` | NVMe solid-state drives. - X = controller index - Y = device index on that controller |
`/dev/nvmeXnYpZ` | Partitions on NVMe storage device. - X = controller index - Y = device index on that controller - Z = partition on that device |
`/dev/null` | Pseudo-device that always outputs EOF (end of file). Output redirected to it is immediately discarded. |
`/dev/random` | Pseudo-device that generates random data (blocking). |
`/dev/sdX` | SCSI or SATA hard drives and other storage devices. Common in modern systems. - X = lower-case letter indicating order of discovery. |
`/dev/sdXY` | Partitions on SCSI or SATA storage device. - X = disk - Y = partition on that disk |
`/dev/srX` | CD-ROM or DVD-ROM drives. - X = index of an optical drive connected to the system |
`/dev/ttyX` | Device file for the terminal. - X = index of a terminal |
`/dev/urandom` | Pseudo-device that generates random data (non-blocking) |
`/dev/vdX` | Virtual storage device. - X = lower-case letter indicating order of discovery |
`/dev/vdXY` | Partitions on a virtual storage device. - X = disk - Y = partition on that disk |
`/dev/videoX` | Device file for a webcam. - X = index of a webcam connected to the system |
Directory/File | Description |
---|---|
`/etc/opt/` | Configuration files for software installed to `/opt`. |
`/etc/security/` | Configuration files for PAM (**P**luggable **A**uthentication **M**odules). |
`/etc/skel/` | Configuration files that are copied to a newly created user's `/home` directory. |
`/etc/X11/` | Configuration files for the X Window System which provides a graphical user interface for Linux. |
`/etc/crontab` | Configuration file uniquely formatted to automate system tasks on a set schedule. |
`/etc/fstab` | Contains information about file systems and partitions automatically mounted at system startup. |
`/etc/group` | Contains information about user groups, including group names and group IDs. |
`/etc/hosts` | Configuration file that maps hostnames to IP addresses. |
`/etc/logrotate.conf` | Configuration file for the `logrotate` utility, managing system log files. |
`/etc/passwd` | Stores user account information such as usernames, user IDs, home directories, and login shells. |
`/etc/profile` | Contains system-wide environment variables and other startup scripts. |
`/etc/resolv.conf` | DNS resolver file which specifies how the system leverages DNS to resolve hostnames. |
`/etc/shadow` | Contains encrypted user passwords and other password-related information. |
`/etc/ssh/sshd_config` | Configuration file for the SSH server, which allows secure remote access to the system. |
`/etc/sudoers` | Contains rules for allowing or denying `sudo` privileges to users and groups. |
**NOTE:** A user's personal home directory can be shortened to `~`.
**NOTE:** Directories and files starting with a period `.` are considered hidden.
Some examples for directories/files in a user's home directory could include:Directory/File | Description |
---|---|
`~/.config/` | Contains configuration files for applications that are specific to a user. |
`~/.gnupg/` | Contains user-specific configuration files for GnuPG (GNU Privacy Guard). |
`~/.local/` | Contains user-specific data files for applications that are installed system-wide. |
`~/.mozilla/` | Contains user-specific configurations and settings for Firefox. |
`~/.ssh/` | Contains user-specific configuration files and private/public keys for SSH (Secure Shell) connections. |
`~/.bashrc`, `~/.zshrc` | Contains user-specific configurations for the user's terminal emulator. |
**NOTE:** On most modern Linux distributions, `/lib` is actually a symbolic link pointing to `/usr/lib`.
The `/lib` directory (or `/lib64` for 64-bit systems) is a crucial component of the operating system. It contains shared libraries that are required by programs in `/bin` and `/sbin` directories, as well as other applications. These libraries provide functionality for many basic system operations, such as networking, file handling, and encryption. Without these libraries, the system would not be able to perform many of its fundamental functions. It is important to ensure that the files in `/lib` are always up-to-date and compatible with the system's other components to guarantee smooth operation. In addition to the shared libraries, the `/lib` directory contains other important files, such as kernel modules (`/lib/modules/`) and firmware files (`/lib/firmware/`). Kernel modules are small programs that can be loaded and unloaded dynamically into the kernel without having to reboot the system. These modules provide additional functionality to the system, such as support for new hardware or file systems. Firmware files, on the other hand, contain low-level software that is used to control hardware devices, such as network adapters (especially WiFi) or graphics cards.Directories/Files | Description |
---|---|
`/lib/firmware/` | Contains firmware files needed by devices to function properly, e.g. WiFi adapters and graphics cards. |
`/lib/security/` | Contains authentication modules for PAM (**P**luggable **A**uthentication **M**odules). |
`/lib/systemd/` | Contains files for the systemd system and service manager. Also contains systemd unit files. |
Directory/File | Description |
---|---|
`/opt/1Password/` | Password manager from Agile Bits |
`/opt/discord/` | Discord VoiP client |
`/opt/google/` | Google Chrome web browser |
`/opt/quake3/` | Quare 3 Arena from id Software |
`/opt/spotify/` | Spotify music streaming client |
`/opt/visual-studio-code/` | Visual Studio Code editor from Microsoft |
Directory/File | Description |
---|---|
`/proc/cpuinfo` | Contains information about the CPU, e.g. model name, number of cores, and clock speed. |
`/proc/meminfo` | Contains memory usage information including swap storage use. |
`/proc/modules` | Contains a list of all the modules being used by the kernel. |
`/proc/swaps` | Contains information only about swap storage. |
`/proc/sys` | Contains files that are used to manage kernel parameters. |
`/proc/version` | Contains Linux version information. |
**NOTE:** On most modern Linux distributions, `/sbin` is actually a symbolic link pointing to `/usr/bin`.
The `/sbin` directory contains essential system binaries that are used for system administration tasks, such as configuring the network or managing user accounts. These files are typically used by system administrators and are not intended for everyday use. ## `/srv` Directory The `/srv` directory is used to store data that is served by the system, and it is typically used by web servers, FTP servers, and other server applications. Other directories that are used for different purposes include:Directory/File | Description |
---|---|
`/srv/ftp/` | Contains files that an FTP server uses to store all of the files that can be accessed by the FTP server. |
`/srv/www/`, `/srv/http/` | Contains files that are served by a web server (sub-directory is distribution specific). |
Directory/File | Description |
---|---|
`/usr/bin/` | Contains executable binaries of applications |
`/usr/bin/gcc/` | Binaries for compiling all sorts of source code of different programming languages |
`/usr/include/` | Source code header files for including functionality of one application into another during development |
`/usr/lib/` | Shared system libraries, e.g. `libc.so` (C library), `libssl.so` (SSL library) |
`/usr/lib/systemd/` | Systemd service unit files |
`/usr/local/` | Typically used to install applications compiled from source, otherwise goes largely unused |
`/usr/share/` | Architecture-independent data files, e.g. game assets, icons, cursors, desktop themes, wallpapers, etc. |
`/usr/share/doc/` | System documentation |
`/usr/share/locale/` | Translations for applications |
`/usr/share/man/` | Application manual pages |
`/usr/src/` | Linux kernel source code files |
Directory/File | Description |
---|---|
`/var/cache/` | Frequently accessed data, e.g. browser cache and downloaded software packages |
`/var/lib/` | Varying application data used by system libraries (e.g. `/var/lib/libvirt/images/` for `libvirt` virtual machine disk images) |
`/var/log/` | Log files of all sorts of different applications |
`/var/mail/` | Locally delivered mail messages |
`/var/mysql/` | MySQL database files |
`/var/spool/` | Printer job queue |