Linux Command Line Guide

Published 08-22-2017 20:20:23

Commands dealing with managing files, directories, compressing and extracting, encrypting, etc…

…can be reviewed in my (THEAARBS) ranger rc.conf file.

Extract commands can be reviewed in my (THEAARBS) extract script.

Secure Shell

Run command [c] as a user [u] on host [h]

ssh [u]@[h] [c]

Run GUI command on host [h] as user [u]

ssh -f -Y [u]@[h] xeyes

Forward connections to host [h]:8080

ssh -g -l 8080:localhost:80 root@[h]

Forward connections from host [h]:1434 to imap

ssh -R 1434:imap:143 root@[h]

Install user [u] public key in host [h] avoiding password requirement at login

ssh -copy-id [u]@[h]

Copy (with permissions) to user [u]’s home directory on the host @[h]

scp -p -r [u]@[h]: [file] [dir]/

Package Management

Install from source

./configure make

Install from .deb package

dpkg -i filename.deb

Install from .rpm package

rpm -Uvh filename.rpm

Install a pacman package

pacman -U filename.tar.pkg.gz

Remove a pacman package and unneeded dependencies

pacman -Rs [package]

Clear pacman cache, force update

pacman -Scc
pacman -Syyu

Refresh pacman keys

pacman-key --refresh-keys

Remove all packages but base group

pacman -R $(comm -23 <(pacman -Qq | sort) <((for i in $(pacman -Qqg base); do pactree -ul "$i"; done) | sort -u))

File Permissions

Change permissions of file to [octal]

chmod \[octal\] \[filename\]

Change permissions of file to rwx for all

chmod 777 filename

Change permissions to rwx for the owner, rw for group and world

chmod 755

System Commands

Show the current date and time


Print current date and who’s online


Set timezone

timedatectl set-timezone America/Chicago

Show the system’s current uptime


Display a list of online users


View your login name


Show kernel information

uname -a

Show CPU information

cat /proc/cpuinfo

Show memory information

cat /proc/meminfo

Display disk usage


Display directory space usage


Show memory and swap usage


Show possible locations for [app]

whereis [app]

Display which [app] will be run by default

which [app]

Linux Swap File


Restart swap service

/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start


mysql -u root -p[root_password] [database_name] > dumpfilename.sql
mysql -u root -p[root_password] [database_name] < dumpfilename.sql


Write ISO image to drive

sudo dd bs=512M if=file.iso of=/dev/sdX