Commands Bible
- Operating System/Kernel
- Hardware
- Graphics
- Networking
- User
- Programs
- Files/Folders
Operating System/Kernel
Show OS/kernel information
Show memory information
Show the kernel log
Show rc init active services (BSDs)
Show all normal users on the system
Show all your storage devices
Show all your configured mountpoints
Show information about your partitions/filesystems
Show the active modules on the kernel
ls /lib/modules/$(uname -r)
Show all available modules on the kernel
ls /lib/modules/$(uname -r)/kernel/drivers/
Show status of the modules on the kernel
Load a module to the kernel (Linux)
sudo modprobe module-name
Load a module to the kernel (BSDs)
Remove a module from the kernel
sudo modprobe -r module-name
Remove a module from the kernel
Unmount one filesystem
Unmount all filesystems except root filesystem
Restart the system (systemd)
Show active swap partition/file
Enable mounted swap (on /etc/fstab or swapfile)
Disable swap
Show the available/active I/O schedulers for your disk (X is your disk letter)
cat /sys/block/sdX/queue/scheduler
Show all available I/O schedulers for all disks
grep "" /sys/block/*/queue/scheduler
Change your active disk I/O scheduler
echo scheduler-name > /sys/block/sdX/queue/scheduler
Hardware
Show CPU information
Show your USB device tree (motherboard ports/bandwidth)
Show your PCI device tree (same as above)
Advanced memory information
Advanced memory information (dmidecode)
Show how fast your hard disk read the data (X is the letter of your disk, use "fdisk -l" to check)
Show all active network interfaces
Show all active wireless network interfaces
Show available CPU governors
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
Show current CPU governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Activate a CPU governor (the most used are "powersave", "performance" and "ondemand")
echo governor-name | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Graphics
Start X11 from terminal (the command on the ".xinitrc" file will run)
Show active program on X11 init config file ("startx" read this file)
Show your OpenGL driver information
Show your Vulkan driver information
Check if you have direct rendering enabled
glxinfo | grep "direct rendering"
Environment variable to make a program use a different Mesa3D driver
MESA_LOADER_DRIVER_OVERRIDE=driver_name program
Environment variable to force a program to use LLVMpipe (OpenGL CPU emulation)
LIBGL_ALWAYS_SOFTWARE=true
(if you want to force all programs of the system to use LLVMpipe add this export LIBGL_ALWAYS_SOFTWARE=true command to your .bashrc file on your user folder or your shell configuration file, it's useful when the OpenGL version of your GPU is too low because your GPU is very old, it will make all games run but you can get very bad FPS if the game is vertex intensive)
Networking
Show system DNS name
Show all network addresses of your system
Ping any website or IP to see if it's online or measure your connection latency
ping website-link or ip-address
Show website registration information
whois https://websitename.com
User
Ctrl+C | This keyboard shortcut cancel any command process
Clean your terminal content/output
Run previous command
Ask root password to switch user for root with echo
Ask current user password to become root
Run as root per-command with root environment variables
Run any command with temporary root privileges and current user environment variables
Run previous command as root temporarily
Exit root privileges or exit terminal session
Current active user on your terminal shell
Environment variable for the current user folder
Show your default terminal shell
Show your current terminal shell
Show your installed terminal shells (active on $PATH)
Change your default terminal shell permanently (common path is /usr/bin)
chsh -s /path/of/your/shell
Add an alias/abbreviation for a command on your terminal shell (add this command on your shell configuration file to be permanent, generally a file named .name-of-your-shell-rc on your user folder)
Change the user password
Show the commands history
Show the commands with the name specified in history
Change the ownership of a file/folder/device/mounted partition (recursively)
sudo chown -R user_name:group-name directory-name
Or
Programs
Show all system-wide common programs
Show all system programs
Show the specified text on terminal
Show the directories in the $PATH environment variable
Show the dependencies (shared libraries) used by a program
Add a new directory on the $PATH environment variable of your terminal shell
export PATH=$PATH:/your/directory
Restore the terminal variables to their default values
Count the time taken for a program to run the command
name* | In some programs the * symbol apply an action to all files with that name
This operator will launch any executable file from the terminal (active directory, run pwd to know)
The "&" operator is used for multitasking on terminal (it don't start the program process as a child of the terminal, but independent from it, so you can close the terminal, similar of what "exec" command does, replacing the shell process by the called program)
Replace the shell by the called program (similar to "&" or "exit")
Run a non-executable sh script
Run a non-executable Bash script
Kill all processes with the specified name
Kill all instances of a running program
Kill all processes of an user
This operator store the output of a task on some file (example: task > file.txt)
This operator store the output of a task on some file but don't overwrite its contents (example: task > file.txt)
This operator apply a command above the output of other program (example: glxinfo | grep OpenGL, this command will search for "OpenGL" inside the output of "glxinfo") - this method is technically known as "Unix pipe"
Download any GitHub repository to the active directory
git clone https://github.com/user-name/repository-name.git
Download any remote Git repository
git clone https://website-name.com/repository-name
Download a Git repository to the specified directory
git clone https://website-name.com/repository-name your/folder
Download any file (as the HTTP protocol headers are flexible, it can download the wrong file, so try to specify the exact file without header problems, generally an exposed extension of the file in the URL "https://website.com/nameofthefile.extension")
wget https://website-name.com/file-name
Resume an incomplete download
wget -c https://website-name.com/file-name
Download any file and try again from where it stopped if the connection failed (by default wget tries 20 times)
wget --tries=anynumber https://website-name.com/file-name
Download from multiple links of a file
Download the entire website and convert it to work locally (offline)
wget --recursive --page-requisites --html-extension --convert-links --no-parent https://website-name.com
Download any file
curl -O https://website-name.com
Resume an incomplete download
wget -C - -O https://website-name.com/file-name
Download files from multiple websites at once
curl -O https://website-name.com -O https://website2-name.com
Example command for custom Wine Prefixes
WINEPREFIX=~/.prefix-name ./wine
Run Wine Explorer from the specified Wine Prefix
WINEPREFIX=~/.prefix-name ./wine explorer
Option to extract AppImage files
Download a torrent with webtorrent-cli and open VLC media player
webtorrent download "magnet:..." --vlc
Choose how many threads will be used for compilation
Install a locally compiled program on the system
Show configuration files of all programs installed on the system
Show the user configuration files of programs
Show files stored by XDG-compliant programs (FreeDesktop standard)
Clean systemd journal logs older than x days ("--vacuum-time=1d" means older than 1 day)
sudo journalctl --vacuum-time=1d
Clean thumbnails cache
rm -rf ~/.cache/thumbnails/*
Package Management
Remove unused dependencies on Debian and Ubuntu
Remove the packages cache on Debian and Ubuntu
This argument example applies an action to all packagess with that name
Or
Fix a incomplete package install on Debian systems
Remove all packages on FreeBSD systems
Files/Folders
Show the current active directory
Change the active directory to the specified folder
Change to the previous directory with echo
Change to the parent directory/folder
Change the active directory to your user folder
Show normal folders/files of the directory
Show all folders/files from a directory, including the hidden ones
Show almost all files/folders, excluding the hidden . and .. Unix tree files
Show the files/folders inside all the folders of the directory
Show all files/folders inside all the folders of the directory, inclusing hidden ones
Show advanced information about the files/folders of the directory
Show the contents of any text file
Search for a text in the specified file format (recursively)
grep -nr "text" --include "*.format"
Search for a text in the specified file name (recursively)
grep -nr "text" --include "file-name.type"
Create a new folder on the active directory
Copy a file to other folder and overwrite on destination
cp file-name destination-folder
Copy a file to other folder, overwrite on destination and maintain the file permissions and timestamps
cp -p file-name destination-folder
Show the files that are being copied (verbose mode)
cp -v file-name destination-folder
Ask if you want to overwrite the file
cp -i file-name destination-folder
Copy a file to other folder, maintain permissions/timestamps, show the file being copied, ask permission to overwrite and make a backup
cp -pvib file-name destination-folder
Copy/overwrite/backup a file to other folder with backup
cp -b file-name destination-folder
Copy multiple files to other folder and overwrite on destination
cp file1 file2 destination-folder
Copy a folder to other folder and overwrite on destination
cp -r folder-name destination-folder
Copy only the things inside the folder and overwrite on destination
cp -r folder-name/. destination-folder
Copy a folder to other folder, maintain permissions/timestamps, show the files being copied, ask permission to overwrite and make a backup
cp -rpvib folder-name destination-folder
Copy multiple folders to other folder and overwrite on destination
cp -r folder1 folder2 destination-folder
Move a file/folder to other folder and overwrite on destination
mv folder-name destination-folder
Or
mv file-name destination-folder
Ask if you want to overwrite the folder
mv -i file-name destination-folder
Move all files with the specified type to the destination folder
mv *.type destination-folder
Move/rename a folder
mv folder-name new-folder-name
Remove/delete a file
Remove/delete any folder recursively without asking for permission (use with caution if you called the command with su/sudo/doas)
Remove an empty directory
Example command to add text on any file
echo "text" >> directory/file
.file-name or .folder-name | A dot before the name of a file/folder make it hidden
Search for files on the directory/subdirectories (run with sudo or su if these directories are under root permissions)
find . -type f -name file-name
Search for folders on the directory/subdirectories (run with sudo or su if the directories are under root permissions)
find . -type d -name folder-name
Show all folders/files/subfolders/subfiles in a tree