Show Menu
Cheatography

Clic Cheat Sheet (DRAFT) by

Arch, Nvim, Tmux, SSH

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Process Management

PS
Show process inform­ation
Show running processes
ps -ef
Show running processes hide threads
pstree -Tp
Show detailed inform­ation about a process
pgrep -a proces­s_name
KILL
Sends a signal to a process usually to stopping a process
Terminate a program using SIGTERM
kill pid
List available signal names
kill -l
Terminate a program using SIGHUP
kill -1 pid
Terminate a porgram using SIGINT
kill -2 pid
Signal the operating system to immedi­ately terminate a program
kill -9 pid
Pause a program until it resumes with the SIGCONT signal
kill -17 pid
Cancel a running process
Ctrl + c
Pause a running process
Ctrl + z
Move process to background
bg %job_id
Move process to foreground
fg %job_id
Remove job from the shell
command & disown
Show status of all jobs
jobs
Show status of a particular job
jobs job_id
Show status and process id's of all jobs
jobs -l
Show process id's of all jobs
jobs -p

Permission

CHOWN
Change user and group ownership of files and folders
Change the owner user of a file or folder
chown username path/t­o/file
Change the owner user and group of a file or folder
chown user:group path/t­o/file
Recurs­ively change the owner of a folder and its contents
chown -R user path/t­o/f­older
Change the owner of a symbolic link
chown -h user path/t­o/s­ymlink
Change the owner of a file or folder to match a reference file
chown --refe­ren­ce=­pat­h/t­o/r­efe­ren­ce_­fil­epa­th/­to/file
CHGRP
Change group ownership of files and folders.
Change the owner of a file or folder
chgrp group path/t­o/file
Recurs­ively change the owner of a folder and its contents
chgrp -R group path/t­o/f­older
Change the owner of a symbolic link
chgrp -h user path/t­o/s­ymlink
Change the owner of a file/f­older to match a reference file
chgrp --refe­ren­ce=­pat­h/t­o/r­efe­ren­ce_file path/t­o/file
CHMOD
Change the access permis­sions of a file or directory
Give the user who owns a file the right to e[x]ecute it
chmod u+x file
Remove executable rights from the group
chmod g-x file
Give the user rights to read and write to a file or directory
chmod u+rw file
Give all users rights to read and execute
chmod a+rx file
Give others (not in the file owner’s group) the same rights as the group
chmod o=g file
User, Group, Other
'u' | 'g' | 'o'
Read, Write, Execute
'r' | 'w' | 'x'
'+' | '-' | '='
Add, Revoke, Set
Octal
0 = None, 1 = execute only, 2 = write only, 3 = write and execute, 4 = read only, 5 = read and execute, 6 = read and write, 7 = read, write and execute (full permis­sion)

Archive

TAR
Create, Compress, Extract files
Create new archive from files
tar -cf name file1 file2 file3
Append files to an existing archive
tar -rf archiv­e_name files/­to/add
List archived files
tar -tvf archiv­e_name
Extract all files
tar -xf archiv­e_name
Extract an archive to specified directory
tar -xf archiv­e_name -C path/t­o/dir
Create a gzipped archive
tar -czf name file1 file2 file3
Create a bzipped archive
tar -cjf archiv­e_name
Extract gzipped archive
tar -xzf archiv­e_name
Extract bzipped archive
tar -xjf archiv­e_name
Create a compressed archive, using archive suffix to determine the compre­ssion
tar -caf archiv­e_n­ame.ta­r.xz, archiv­e_n­ame.gz, archiv­e_n­ame.bz file1 file2 file3

Storage Media

Show all mounted filesy­stems
mount
Mount a device to a directory
mount path/t­o/dev path/t­o/dir
Mount all the filesy­stems defined in /etc/fstab
mount -a
Unmount a filesystem
umount path/t­o/d­evice
Fsck (Dry Run)
fsck -N /path/­to/dev
Check for filesystem errors
fsck path/t­o/dev
Fix detected errors
fsck -y /path/­to/dev
Show partitions
fdisk -l
Run fdsik
fdisk /dev/t­arg­et/­device
Create filesystem
mkfs.ext2 /path/­to/dev [ext3, ext4, btrfs, ntfs]
Create filesystem with a volume­-label
mkfs.ntfs -L name /path/­to/dev
Create filesystem with specific UUID
mkfs.ntfs -U UUID /path/­to/dev
Mkfs (Dry Run)
mkfs.ext4 -vv
Create a bootable usb media from a iso image
dd bs=8M if=/pa­th/­to/iso of=/de­v/u­sb_­drive conv=fsync oflag=­direct status­=pr­ogress

Secure Shell Host (SSH)

SSH
Secure Shell is a protocol used to securely log onto remote systems. It can be used for logging or executing commands on a remote server.
Connect to a remote server
ssh userna­me@­rem­ote­_host
Connect to a remote server with a specific identity (private key)
ssh -i path/t­o/k­ey_file userna­me@­rem­ote­_host
Connect to a remote server using a speciific port
ssh -p 23 userna­me@­rem­ote­_host
Execute a command on a remote server
ssh remote­_host "­exa­mpl­e_c­omm­and­"
Compress all data if the connection is slow
ssh -C userna­me@­rem­ote­_host
Print debug inform­ation
ssh -v userna­me@­rem­ote­_host
Enable X11 forwarding
ssh -X userna­me@­rem­ote­_host
Generate SSH keys
ssh-keygen
Copy puplic SSH key to a server
ssh-co­py-id ip_adress
SCP
Secure copy files over ssh
Copy a local file to a remote host
scp path/t­o/file userna­me@­rem­ote­_ho­st:­pat­h/t­o/save
Copy a file from a remote host to your local directory
scp userna­me@­rem­ote­_ho­st:­pat­h/t­o/r­emo­te_file path/l­oca­l/dir
Recurs­ively copy the contents of a directory on a remote host to a local directory
scp -r path/t­o/l­oca­l_dir remote­_ho­st:­pat­h/t­o/save
Use a specific ssh private key for authen­tic­ation with the remote host
scp -i ~/.ssh­/pr­iva­te_key local_file remote­_ho­st:­pat­h/t­o/save
Use a speciific port
scp -P 23 path/t­o/file userna­me@­rem­ote­_ho­st:­pat­h/t­o/save
Copying multiple files to a remote host
scp file1 file2 userna­me@­rem­ote­_ho­st:­pat­h/t­o/save
Copying multiple file from remote host
scp userna­me@­loc­alh­ost­:pa­th/­to/­{file1, file2}

Kernel module handling

Show active kernel modules
lsmod
Show inform­ation about a specific kernel module
modinfo modulename
Insert a module into the Linux Kernel
insmod modulename
Remove a module from the Linux Kernel
rmmod modulename
Generate a list of dependency descri­ption of kernel modules
depmod
MODPROBE
Add and remove modules form the Linux Kernel
Insert kernel modules
modprobe -a module­name1 module­name2
Remove kernel module
modprobe -r module­name1 module­name2
Prints current config­uration
modprobe -c
Modprobe (Dry Run)
modprobe --show
Print messages about what the program is doing
modprobe -v

File Searching

FIND
It can be used to find files and direct­ories and perform subsequent operations on them
Search by name case sensitive
find /dir -name "­sea­rch­_te­rm"
Search by name case insens­itive
finde /dir -iname "­sea­rch­_te­rm"
Search by file type d=dir, f=file
find /dir -type f
Search by wildcard
find /dir "search­_te­rm", "­sea­rch­_term"
Search and execute a command
find /dir -exec command {} \;
PLOCATE
find files by name
Search for files
plocate search­_term

Tmux

TMUX
Terminal Multip­lexer (prefix ctrl + a)
Enter copy mode
prefix + pageup
Choose a session from a list
prefix + s
Choose a window from a list
prefix -w
Show a clock
prefix -t
Zoom active pane rather maximize
prefix - z
Resize the pane up by 5
prefix + alt + up (arrow keys)
Resize the pane down by 5
prefix + alt + down (arrow keys)
Resize the pane left by 5
prefix + alt + left (arrow keys)
Resize the pane right by 5
prefix + alt + right (arrow keys)
Break the pane out and maximize to fullscreen
prefix + shift + !
Create a new window
prefix + c
Switch the attached client to the next session
prefix + shift + )
Switch the attached client to the previous session
prefix + shift + (
Select window
prefix + 0 to 9

Kitty

KITTY
Terminal emulator (prefix ctrl + shift)
New window
prefix + enter
Select window
prefix + 1
Open new tab
prefix + t
Close tab
prefix + t
Next tab
prefix + right (arrow key)
Previous tab
prefix + left (arrow key)
Set tab title
prefix + alt + t
Rezise window or pane
prefix + r
Edit kitty config file
prefix + F2

User account admini­str­ation

Create a user account
useradd username
Modify a user account
usermod username
Delete a user account
deluser username
Change user password
passwd username

Miscel­laneous

ALIAS
Creates aliases words that are replaced by a command string
Create a generic alias
word="c­omm­and­"
Remove an aliased command
unalias word
List all aliased words
alias -p
View the command associated to a given alias
alias word
CAL
Prints calendar inform­ation
Display calendar for the current month
cal
Display calendar for a specific month
cal month_­number
Display a 12 month calendar for the current year
cal -y
ECHO
Display a line of text
Print a text message
echo exampl­e_text
Redirect input to a file
echo exampl­e_text >> filename
Verify ISO files with sha1sum
echo "­has­h" isoname | sha1sum -c
FILE
Determine file type and give a descri­ption of the type of the specified file
Determine file type
file path/t­o/file
Determine the mime encoding type of a file
file -i path/t­o/file
Try to look inside compressed files
file -z path/t­o/file
Try to look inside compressed files but report inform­ation about the contens
file -Z path/t­o/file
MAN
Display manual pages
Dsiplay man page for a command
man command