Shell

Updated at
BasicsCommand
Diff side to sidediff file1 file2 [-q] (report only if differ), [-y] (side by side)
Show permissionsstat <file> (shows detailed file info, including permissions and timestamps)
Check groupgroups (shows all groups current user belongs to)
Show usernamewhoami (prints the username of the user currently logged in)
User infoid (shows user ID and group IDs of current user)
Word countwc [-c] (bytes), [-m] (chars), [-l] (lines), [-w] (words)
Determine file typefile <filename> (determines the type of file, e.g., text, binary, etc.)
Find filesfind <path> [-iname filename] (case-insensitive match for filename)
Regex Searchgrep -E <pattern> (extended regex)
Grep flags[-h] (no filename), [-n] (line numbers), [-i] (ignore case), [-v] (invert match)
Access managementCommand
Create a useradduser <username>
Grant sudo rightsusermod -aG sudo <username> (append user to the sudo group)
Change permissionschmod [+-=][rwx] file (e.g., chmod +x script.sh to make it executable)
Change ownerchown [username][:group] file (change owner and/or group)
Generate SSH keyssh-keygen -t ed25519 [-C "comment"] (optional comment)
Install SSH key on hostssh-copy-id -i ~/.ssh/id_ed25519.pub username@host
Disable password loginEdit /etc/ssh/sshd_config: set PasswordAutherntication no
Reload SSH servicesudo systemctl reload ssh
Check password loginssh username@host -o PubkeyAuthentication=no
Host ManagementCommand
Set new FQDN hostnamesudo hostnamectl set-hostname <hostname>
Check FQDN hostnamehostname --fqdn
Check DNS domaindnsdomainname
Set timezonesudo timedatectl set-timezone Europe/Riga
Check current logged-in usersw
Check login historylast -a
Check failed login attemptslastb -adF
Switch to another usersu <user>
Show command historyhistory
View service logsjournalctl
Process ManagementCommand
Interactive process monitorhtop
Process monitortop
View all processesps -axu
Monitor network bandwidthiftop
Network statisticsnetstat -la
Storage ManagementCommand
Disk usage visualizationncdu
Disk space usagedf -h
Directory size summarydu -hsc *
Stream FlowSyntax
Redirect stdout (overwrite, append)>, >>
Redirect stderr (overwrite, append)2>, 2>>
Redirect out and err> file 2>&1
Redirect stdin<
Pipe left output to right input|
Drop output> /dev/null