LINUX Commands and useful applications

Some useful Linux command, applications and cheat sheet.


CONTENT


LINUX TERMINAL COMMANDS CHEAT SHEET

Application and Process

whereis

Locate the binary, source, and manual page files for a command.

which

Get the full path to a command's executable file.

apt

Search, install, remove, and update packages and dependencies for Debian, Linux Mint, Ubuntu.

dnf

Search, install, remove, and update packages and dependencies for Fedora, CentOS, and Red Hat Enterprise Linux (RHEL).

pacman

Search, install, remove, and update packages and dependencies for Arch Linux, CachyOS, Manjaro.

zypper

Search, install, remove, and update packages and dependencies for openSUSE.

Console and Output

cat

Display file contents on the terminal.

clear

lear the terminal display.

echo

Print text or variables in the terminal.

top

Get information about running processes.

Environment Variables

env

Display all environment variables running on the system.

export

Export environment variables.

printenv

Print a particular environment variable to the console..

source

Execute commands stored in a file from within the current shell, or refresh environment variables.

Files and Directories

cd

Change to another directory.

cp

Copy the contents of the source directory or file to a target directory or file.

find

Locate a file or directory by name.

grep

Search for a string within an output.

ls

List the contents of a directory.

mkdir

Create directories.

more

View and traverse the content of a file or stdout.

mv

Move or rename files.

pwd

Get the name of the present working directory.

rm

Delete files or directories.

tar

Extract and compress files.

Documentation and Help

man

Access manual pages for all Linux commands.

tldr

Collaborative cheatsheets for console commands. Website | GitHub

wikiman

Offline search engine for manual pages, Arch Wiki, Gentoo Wiki and other documentation. GitHub

Network

curl

Get or post a file to or from the Internet according to a URL.

ip

Gets the IP information for the physical or virtual machine.

netstat

Get information about network connections and more.

ssh

Establish a secure encrypted connection between two hosts over an insecure network.

wget

Direct download files from the Internet.

Process

&&

Execute commands in a sequence.

kill

Removes a running process from memory.

ps

Display active processes.

Sound

alsamixer

alsamixer is an ncurses mixer program for use with the ALSA soundcard drivers. It supports multiple soundcards with multiple devices.

System

reboot

Restart a computer.

poweroff

Shut down a computer.

restart

Restart a computer.

User

whoami

Display the user ID.


FILE NAVIGATION

List directories (with type indicator)

ls --file-type

Change directory to "example"

cd example

Move up one directory

cd ..

Move up two directories

cd ../..

Change to home directory

cd ~

Get absolute path to a file or folder

readlink -f example

Get file type of "example.ext"

file example.ext

FILE MANAGEMENT

Copy a file in place

cp example.txt example-1.txt

Copy a file to Documents

cp example.txt ~/Documents/example-1.txt

Move a file to Documents

mv example.txt ~/Documents

Remove a file

rm example.txt

Create a directory (folder)

mkdir example

Remove an empty directory

rm example

Remove a directory recursively

rm -r example

Permanently delete a file (secure)

shred example.txt

Download a file from a network location

wget https://example.com/file

SOFTWARE MANAGEMENT

  • On Fedora and CentOS, [COMMAND] is dnf
  • On Debian, Linux Mint, Ubuntu [COMMAND] is apt
  • On OpenSUSE, [COMMAND] is zypper
  • Other distributions may use different commands

Search for an application called example

sudo [COMMAND] search example

Install an application called example

sudo [COMMAND] install example

Uninstall an application called example

sudo [COMMAND] remove example

SERVICES MANAGEMENT
"example" can be bluetooth

Start services

sudo systemctl start example

Restart services

sudo systemctl restart example

Stop services

sudo systemctl Stop example

Get status of services

sudo systemctl status example

Enable services

sudo systemctl enable --now example

Disable services

sudo systemctl disable --now example

SYSTEM MANAGEMENT

Get system, machine, CPU and GPU info

inxi -MSCG

Reboot and enter BIOS/UEFI

systemctl reboot --firmware-setup


APPLICATIONS

CryFS - Keep your data safe in a vault

CryFS encrypts your files, so you can safely store them anywhere. It works well together with cloud services like Dropbox, iCloud, OneDrive and others.

Setup an encrypted directory (vault)

Once installed, you can create an encrypted directory by calling cryfs basedir mountdir in the terminal. You can name the directories like you want, basedir and mountdir are used for demonstration purposes. If the corresponding directories don't exist yet, CryFS will offer to create them for you.

cryfs basedir mountdir

Mount the encrypted directory

The command below will mount the mountdir, in other words, open the vault, where you put your files.

cryfs basedir mountdir

Unmount the encrypted directory

The command below will unmount mountdir, in other words, close the vault and secure the access of your files.

cryfs-unmount mountdir

Summary

basedir is the directory where your files are encrypted.

mountdir is a virtual unencrypted representation of your vault, this is where you add or remove files and directories.

fwupdmgr - firmware update manager client utility

fwupdmgr is a command line fwupd client intended to be used interactively. The output between versions of fwupd is not guaranteed to be stable.

Install fwupd first if is not on your system yet: apt install fwupd

Get all devices that support firmware updates fwupdmgr get-devices Refresh metadata from remote server fwupdmgr refresh Gets the list of updates for connected hardware fwupdmgr get-updates Updates all devices to latest firmware version fwupdmgr update

inxi

inxi is a command line system information script built for console and IRC. It is also used a debugging tool for forum technical support to quickly ascertain users' system configurations and hardware. inxi shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, gcc version(s), Processes, RAM usage, and a wide variety of other useful information.

Get basic info inxi -b Get Audio info inxi -A Get Battery info inxi -B Get CPU info inxi -C Get Full info inxi -F Get GPU info inxi -G Get Machine and System info inxi -MS

lsblk

lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.

Get basic info lsblk Output info about filesystems lsblk -f