Linux-Cli-Tutorial(by Saman Khalife)
  • Characters
  • Linux Commands
  • Quick review for commands
  • Config file parameters you can use
  • .github
    • ISSUE_TEMPLATE
      • bug_report
  • Editors-for-command-line
  • TOOLs and APPs
    • Iptables
    • Ufw
      • man
  • Git Commands
  • Installing tools and apps
    • Check-used-ports
    • Clear the cache memory in Linux
    • ulimit
    • ulimit
    • Installing WordPress with Apache
    • Installing WordPress with Nginx
    • what packages are installed by apt
    • wildcard characters for globbing
  • Lpic 1
    • LPIC-1 Exam 101 (101-500) Exam
    • LPIC-1 Exam 101 Objectives
    • how to use lvm snapshots
    • LPIC-1 Exam 102 Objectives
  • Lpic 2
    • how to use lvm
    • LPIC-2 Exam 201 Objectives
    • LPIC-1 Exam 102 (102-500) Exam
    • LPIC-2 Exam 202 Objectives
  • Lpic 3
    • LPIC-2 Exam 201 (201-450) Exam
    • LPIC-3 High Availability and Storage Clusters 306 Objectives
    • LPIC-2 Exam 202 (202-450) Exam
    • LPIC-3 Mixed Environments 300 Objectives.md
    • LPIC-3 High Availability and Storage Clusters 306 Exam
    • LPIC-3 Security Exam 303 Objectives
    • LPIC-3 High Availability and Storage Clusters 306 Objectives
    • LPIC-3 Virtualization and Containerization 305 Objectives
  • TXT FILES
    • accept
    • accton
    • aclocal
    • acpi
    • acpid
    • addr2line
    • addresses
    • agetty
    • alias
    • alsactl
    • amidi
    • amixer
    • anacron
    • apachetop
    • aplay
    • aplaymidi
    • apm
    • apmd
    • apropos
    • apt-get
    • apt
    • aptitude
    • ar
    • arecord
    • arecordmidi
    • arp
    • aspell
    • at
    • atd
    • atop
    • aumix
    • autoconf
    • autoheader
    • automake
    • autoreconf
    • autoscan
    • badblocks
    • banner
    • basename
    • batch
    • bc
    • bg
    • biff
    • bind
    • bison
    • break
    • builtin
    • bzcmp
    • bzdiff
    • bzgrep
    • bzip2
    • cal
    • cardctl
    • cardmgr
    • case
    • cat
    • cc
    • ccrypt
    • cd
    • cdparanoia
    • cfdisk
    • chage
    • chdir
    • chfn
    • chgrp
    • chkconfig
    • chmod
    • chown
    • chpasswd
    • chroot
    • chrt
    • chsh
    • chvt
    • cksum
    • clorm
    • cloumn
    • cmp
    • comm
    • compress
    • continue
    • cp
    • cpio
    • cron
    • crond
    • crontab
    • csplit
    • ctags
    • cupsd
    • curl
    • cut
    • cvs
    • date
    • dd
    • ddrescue
    • debugfs
    • declare
    • depmod
    • devdump
    • df
    • diff
    • dig
    • dircolors
    • dirname
    • disable
    • dlpsh
    • dmesg
    • dmidecode
    • dnsdomainname
    • dnssec-makekeyset
    • dnssec-signkey
    • dnssec-signzone
    • dnssec
    • doexec
    • domainname
    • dosfsck
    • dstat
    • du
    • dump
    • dumpe2fs.
    • dumpkeys
    • e2fsck
    • e2image
    • e2label
    • echo
    • ed
    • edquota
    • eject
    • elvtune
    • emacs
    • enable
    • env
    • envsubst
    • esd-config
    • esd
    • esdcat
    • esdctl
    • esddsp
    • esdmon
    • esdplay
    • esdrec
    • esdsample
    • etags
    • ethtool
    • eval
    • ex
    • exec
    • exit
    • expand
    • expect
    • export
    • expr
    • factor
    • false
    • fc-cache
    • fc-list
    • fc
    • fdformat
    • fdisk
    • fg
    • fgrep
    • file
    • find
    • finger
    • flex
    • fmt
    • fold
    • for
    • formail
    • format
    • free
    • fsck
    • ftpd
    • function
    • g++
    • gawk
    • gdb
    • getent
    • getkeycodes
    • getopts
    • goaccess
    • gorupmod
    • gpasswd
    • gpgsplit
    • gpgv
    • gpm
    • gprof
    • grep
    • groff
    • groffer
    • groupadd
    • groupdel
    • groups
    • grpck
    • grpconv
    • gs
    • gunzip
    • gzexe
    • gzip
    • halt
    • hash
    • hdparm
    • head
    • help
    • hexdump
    • history
    • host
    • hostid
    • hostname
    • hostnamectl
    • htdigest
    • htop
    • hwclock
    • iconv
    • id
    • if
    • ifconfig
    • iftop
    • ifup
    • import
    • inetd
    • info
    • init
    • insmod
    • install
    • iostat
    • iotop
    • ip
    • ipcrm
    • ipcs
    • iptables-restore
    • iptables
    • isodump
    • isoinfo
    • isosize
    • isovfy
    • ispell
    • iwconfig
    • jnettop
    • jobs
    • join
    • journalctl
    • kbdrate
    • kill
    • killall
    • klogd
    • kudzu
    • last
    • lastlog
    • ld
    • ldconfig
    • ldd
    • less
    • lesskey
    • let
    • lftp
    • lftpget
    • link
    • ln
    • loadkeys
    • local
    • locate
    • lockfile
    • logger
    • login
    • logout
    • logrotate
    • logwatch
    • look
    • losetup
    • lpadmin
    • lpc
    • lpinfo
    • lpmove
    • lpq
    • lpr
    • lprint
    • lprintq
    • lprm
    • lpstat
    • ls
    • lsatb
    • lsattr
    • lsblk
    • lshw
    • lsmod
    • lsof
    • lspci
    • lsusb
    • mail
    • mailstats
    • make
    • makedbm
    • makemap
    • man
    • manpath
    • mattrib
    • mbadblocks
    • mcat
    • mcd
    • mcopy
    • mdu
    • merge
    • mesg
    • mformat
    • mkdir
    • mkfs
    • mkraid
    • mktemp
    • mlabel
    • mmove
    • modinfo
    • LPIC-3 Mixed Environments 300 Exam
    • most
    • mount
    • mountd
    • mpartition
    • mpstat
    • mv
    • named
    • nameif
    • neofetch
    • netcat
    • netstat
    • newaliases
    • newgrp
    • newusers
    • nfsstat
    • nice
    • nl
    • nm
    • nmcli
    • nohup
    • nslookup
    • nsupdate
    • objcopy
    • objdump
    • od
    • op
    • open
    • openvt
    • passwd
    • paste
    • patch
    • pathchk
    • pgrep
    • pidof
    • ping
    • pkill
    • pmap
    • popd
    • portmap
    • poweroff
    • pppd
    • pr
    • praliases
    • printcap
    • printenv
    • printf
    • ps
    • ptx
    • pushd
    • pv
    • pwck
    • pwconv
    • pwd
    • quota
    • quotacheck
    • quotactl
    • quotaoff
    • quotaon
    • quotastats
    • raidstart
    • ram
    • ramsize
    • ranlib
    • rar
    • rarpd
    • rcp
    • rdev
    • rdist
    • read
    • readarray
    • readcd
    • readelf
    • readlink
    • readonly
    • reboot
    • reject
    • rename
    • renice
    • repquota
    • reset
    • restore
    • return
    • rev
    • rexecd
    • rlogin
    • rlogind
    • rm
    • rmail
    • rmdir
    • rmmod
    • rndc
    • rootflags
    • route
    • routed
    • rpcgen
    • rpcinfo
    • rpm
    • rsh
    • rshd
    • rsync
    • runlevel
    • rup
    • rusers
    • rusersd
    • rwall
    • rwho
    • rwhod
    • sane-find-scanner
    • sar
    • scanadf
    • scanimage
    • scp
    • screen
    • script
    • scriptreplay
    • sdiff
    • sed
    • select
    • sensors
    • seq
    • service
    • set
    • setfdprm
    • setkeycodes
    • setleds
    • setmetamode
    • setquota
    • setsid
    • setterm
    • sftp
    • sh
    • shift
    • shopt
    • showkey
    • showmount
    • shred
    • shutdown
    • skill
    • slabtop
    • slacttach
    • sleep
    • slocate
    • snice
    • sort
    • source
    • split
    • ss
    • ssh-add
    • ssh-agent
    • ssh-keygen
    • ssh-keyscan
    • ssh
    • stat
    • statd
    • strfile
    • strings
    • strip
    • stty
    • su
    • sudo
    • sum
    • suspend
    • swapoff
    • swapon
    • symlink
    • sysctl
    • sysklogd
    • syslogd
    • systemctl
    • Systemd
    • tac
    • tail
    • tailf
    • talkd
    • tar
    • taskset
    • tcpdump
    • tcpslice
    • tee
    • telinit
    • telnet
    • terminator
    • tfdp
    • tftpd
    • tmpwatch
    • top
    • touch
    • tput
    • tr
    • tracepath
    • traceroute
    • trap
    • tree
    • tset
    • tty
    • tune2fs
    • tunelp
    • type
    • ul
    • unalias
    • uname
    • uncompress
    • unexpand
    • unicode_start
    • unicode_stop
    • uniq
    • units
    • unix2dos
    • unshar
    • until
    • uptime
    • useradd
    • usermod
    • usleep
    • uudecode
    • uuencode
    • uuidgen
    • vidmode
    • vmstat
    • vnstat
    • w
    • wall
    • warnquota
    • watch
    • wc
    • wget
    • whatis
    • which
    • while
    • who
    • whoami
    • write
    • xargs
    • xdg-open
    • xinetd
    • xz
    • yacc
    • ypbind
    • ypcat
    • ypinit
    • ypmatch
    • yppasswd
    • yppasswdd
    • yppoll
    • yppush
    • ypset
    • yptest
    • ypwhich
    • ypxfr
    • zcat
    • zcmp
    • zdiff
    • zdump
    • zforce
    • zgrep
    • zic
    • zip
    • zless
    • znew
    • readme
      • Some basic info about Cloud Computing model and SRE's
      • Ansible Automation
      • Backup and Recovery
      • Linux File Systems and Storage Management
      • Linux Networking
      • shell-scripting
      • LPIC-3 Mixed Environments 300 Objectives
    • File-systems-Cocepts
      • LPIC1-101
        • LPIC-3 Security Exam 303 Exam
        • /dev/
        • /etc/apt/sources.list
        • /etc/fstab
        • /etc/init.d/
        • LPIC-3 Virtualization and Containerization 305 Exam
        • /etc/ld.so.conf
        • /etc/systemd
        • /etc/yum.conf
        • /etc/yum.repos.d/
        • LPIC-3 Virtualization and Containerization 305 Objectives
        • /media
        • /proc/
        • modprobe
        • /sys/
        • /usr/lib/systemd/user/
        • -boot
        • .bash_history
        • Application container
        • BIOS
        • D-Bus machine ID
        • EFI System Partition
        • Guest drivers
        • LD_LIBRARY_PATH
        • Linux containers
        • MBR
        • Quoting
        • SSH host keys
        • SysVinit
        • UEFI
        • VFAT
        • VMs
        • XFS
        • -etc-inittab
        • -home
        • bootloader
        • -root
        • -var
        • dpkg-reconfigure
        • apt-cache
        • bash
        • exFAT
        • ext2/ext3/ext4
        • bunzip2
        • bzcat
        • dpkg
        • Grub-install
        • grub-mkconfig
        • initramfs
        • kernel
        • egrep
        • file globbing
        • filesystem
        • gdisk
        • menu.lst, grub.cfg and grub.conf
        • Partitions
        • regex(7)
        • rpm2cpio
        • sha256sum
        • sha512sum
        • mke2fs
        • mkswap
        • mount points
        • parted
        • swap space
        • tmux
        • umask
        • umount
        • unset
        • unxz
        • updatedb
        • whereis
        • xfs_db
        • xfs_fsr
        • xfs_repair - Copy (2)
      • LPIC1-102
        • xfs_repair
        • xzcat
        • yum
        • zypper
        • -etc-X11-xorg.conf
        • -etc-X11-xrog.conf.d
        • -etc-at.allow
        • -etc-at.deny
        • -etc-bash.bashrc
        • -etc-chrony.conf
        • -etc-cron.allow
        • -etc-cron.deny
        • -etc-cron
        • -etc-crontab
        • -etc-cups
        • -etc-group
        • -etc-hostname
        • -etc-hosts.allow
        • -etc-hosts.deny
        • -etc-hosts
        • -etc-init.d-
        • -etc-inittab
        • -etc-localhost
        • -etc-localtime
        • -etc-logrotate.conf
        • -etc-logrotate.d-
        • -etc-nologin
        • -etc-nsswitches.conf
        • -etc-nto.conf
        • -etc-ntp.conf
        • -etc-passwd
        • -etc-profile
        • -etc-resolv.conf
        • -etc-rsyslog.conf
        • -etc-services
        • -etc-shadow
        • -etc-skel-
        • -etc-ssh-ssh_host_dsa_key and ssh_host_dsa_key.pub
        • -etc-ssh-ssh_host_ecdsa_key and ssh_host_ecdsa_key.pub
        • -etc-ssh-ssh_host_ed25519_key and ssh_host_ed25519_key.pub
        • -etc-ssh-ssh_host_rsa_key and ssh_host_rsa_key.pub
        • -etc-sudoers
        • -etc-systemd-journald.conf
        • -etc-timezone
        • -etc-updatedb.conf
        • -etc-xinetd.conf
        • -etc-xinetd.d-
        • -usr-bin-locale
        • -usr-share-zoneinfo
        • -usr-share-zoninfo
        • -var-log-journal
        • -var-log
        • DISPLAY
        • -var-spool-cron
        • ASCII
        • Gnome
        • Braille Display.
        • CUPS configuration files, tools and utilities
        • Gesture
        • KDE
        • Gestures.
        • High ContrastLarge Print Desktop Themes.
        • IPv4-IPv6
        • ISO-8859
        • LANG
        • LC_
        • LC_ALL
        • Logical OR
        • Mouse keys
        • On-Screen Keyboard.
        • RDP
        • Screen Magnifier.
        • Screen Reader
        • Slow-Bounce-Toggle keys
        • Spice
        • Sticky-Repeat keys
        • Subnetting
        • TCP-UDP-ICMP
        • TZ
        • X
        • UTF-8
        • XDMCP
        • Xfce
        • Unicode
        • VNC
        • Voice recognition
        • X11
        • atq
        • atrm
        • chronyc
        • exim
        • fuser
        • gpg-agent
        • gpg
        • groupmod
        • ifdown
        • logic and
        • logic or
        • lpd legacy interface
        • mailq
        • nmap
        • ntpd
        • ntpdate
        • ping6
        • pool.ntp.org
        • postfix
        • sendmail emulation layer commands
        • sendmail
        • ssh_known_hosts
        • systemd-cat
        • systemd-run
        • systemd.socket
        • test
        • timedatectl
        • tracepath6
        • traceroute6
        • tzselect
        • xauth
        • ulimit
        • unset
        • userdel
        • who, w, last
        • xhost
        • ~-.bash_login
        • ~-.bash_logout
        • ~-.bash_profile
        • ~-.bashrc
        • ~-.forward
        • ~-.gnupg-
        • ~-.profile
        • ~-.ssh-authorized_keys
        • ~-.ssh-id_dsa and id_dsa.pub
      • LPIC2-201
        • /bin/dmesg
        • /bin/uname
        • Device Naming Conventions
        • /dev/mapper/
        • /etc/auto.[dir]
        • /etc/auto.master
        • ~-.ssh-id_ecdsa and id_ecdsa.pub
        • /etc/hostname and /etc/HOSTNAME
        • /etc/hosts.allow , /etc/hosts.deny
        • /etc/hosts
        • /etc/init.d/
        • /etc/inittab
        • /etc/mtab
        • /etc/network and /etc/sysconfig/network-scripts
        • /etc/rc.d/
        • /etc/resolv.conf
        • /etc/sysctl.conf
        • /etc/systemd/
        • /etc/udev/
        • /proc/mdstat
        • ~-.ssh-id_ed25519 and id_ed25519.pub
        • /proc/sys/kernel/
        • /run/systemd/
        • /sbin/depmod
        • /sbin/insmod
        • /sbin/lsmod
        • /sbin/lspci
        • lv
        • /sbin/modinfo
        • /sbin/modprobe
        • pv
        • /sbin/rmmod
        • ~-.ssh-id_rsa and id_rsa.pub
        • LVM Volume Group (vg)
        • /usr/bin/lsdev
        • /usr/bin/lsusb
        • /usr/src
        • EFI System Partition (ESP)
        • GRUB
        • Master boot record
        • ~-.xsesion-errors
        • /boot , /boot/grub , /boot/efi
        • UEFI shell
        • WWID, WWN, LUN numbers
        • blkid
        • blocks in
        • blocks out
        • btrfs, btrfs-convert
        • bzImage
        • -etc-fstab
        • configure
        • cryptsetup
        • diagnose
        • dkms
        • efiboot.img
        • efibootmgr
        • Extlinux
        • fsck
        • -proc-mounts
        • fstrim Command
        • grub-install
        • -sbin-sysctl
        • System log files such as -var-log-syslog, -var-log-messages and the systemd journal
        • initrd and initramfs
        • SysV Init Overview
        • iSCSI Components
        • isohdpfx.bin
        • ISOLINUX
        • chkconfig
        • iw
        • iwlist
        • lib/modules/kernel-version/modules.dep
        • fsck
        • lvm.conf
        • make targets
        • mdadm.conf
        • mdadm
        • mkfs
        • mkinitramfs
        • mkinitrd
        • mkisofs
        • mkswap
        • /etc/modprobe.d/
        • module tools
        • mount and umount
        • hdparm, sdparm
        • mtr (My Traceroute)
        • Netcat(nc)
        • Nmap
        • NVMe (Non-Volatile Memory Express)
        • partition type 0xFD
        • ping , ping6
        • predict growth
        • processes blocked on IO
        • pxelinux.0
        • pxelinux.cfg/
        • resource exhaustion
        • smartd, smartctl
        • init and telinit
        • isolinux.cfg
        • sync
        • sysctl
        • syslinux
        • lib-modules-kernel-version
        • systemd-delta
        • mount
        • swapoff
        • tune2fs
        • udevadm monitor
        • udevmonitor
        • uefi-grubx64.efi
        • uefi-shim.efi
        • update-rc.d
        • /usr/lib/systemd/
        • usr-src-linux-.config
        • /usr/src/linux
        • /usr/src/linux/Documentation/
        • Xfs_info, Xfs_check, Xfs_repair, Xfsdump and Xfsrestore
        • XZ
        • zImage
      • LPIC2-202
        • /etc/aliases
        • /etc/dovecot
        • /etc/exports
        • /etc/fstab
        • named.conf
        • /etc/nginx
        • /etc/openvpn
        • /etc/passwd
        • /etc/postfix/
        • /etc/samba/
        • /etc/services
        • /etc/ssh/sshd_config
        • /etc/ssh
        • -etc-ssl-, -etc-pki-
        • /proc/mounts
        • /proc/sys/net/ipv4/
        • /proc/sys/net/ipv6/
        • /etc/samba/
        • /var/named/
        • swapon
        • systemctl
        • .htaccess Files
        • Apache2 configuration files
        • AuthUserFile, AuthGroupFile
        • Conditions and comparison operators
        • Configuration files and commands for postfix
        • DHCP Log Messages in Syslog or Systemd Journal
        • DNSSEC
        • traceroute, traceroute6
        • LDIF (LDAP Data Interchange Format)
        • PermitRootLogin, PubKeyAuthentication, AllowUsers, PasswordAuthentication, Protocol
        • Private and public key files
        • SSLCACertificateFile, SSLCACertificatePath
        • SSLEngine, SSLCertificateKeyFile, SSLCertificateFile
        • SSLProtocol, SSLCipherSuite, ServerTokens, ServerSignature, TraceEnable
        • Access Logs:
        • ACL
        • apachectl, apache2ctl
        • tune2fs, dumpe2fs and debugfs
        • dhcpd.conf
        • dhcpd.leases
        • dhcpd
        • dnssec-keygen
        • dnssec-signzone
        • doveadm
        • doveconf
        • dovecot.conf
        • /etc/pam.d
        • exportfs
        • Fail2ban
        • htpasswd
        • http_access
        • httpd, apache2
        • httpd.conf
        • Important Pure-FTPd command line options
        • ip6tables
        • -var-named
        • ldapadd
        • ldapdelete
        • ldappasswd
        • ldapsearch
        • -var-spool-postfix
        • Mail-related logs in /var/log/
        • Master File Format in DNS
        • mod_auth_basic, mod_authz_host and mod_access_compat
        • mount.cifs
        • named-checkconf
        • named-checkzone
        • named-compilezone
        • net
        • Dovecot vacation extension
        • nsswitch.conf
        • OpenSSL
        • OpenVPN
        • pam.conf
        • pam_unix, pam_cracklib, pam_limits, pam_listfile, pam_sss
        • portmapper
        • radvd.conf
        • radvd
        • Resource Record Formats
        • rpcinfo
        • samba-tool
        • Sendmail emulation layer commands
        • slapadd
        • slapcat
        • slapd-config
        • arp
        • keep, fileinto, redirect, reject, discard, stop
        • smbclient
        • Additional Samba Commands: smbcontrol, smbstatus, testparm, smbpasswd, nmblookup
        • SMB Daemons: smbd, nmbd, winbindd
        • squid.conf
        • sshd
        • sssd.conf
        • loglevel
        • vsftpd.conf
        • zone file syntax
      • LPIC3-300
        • IPC$
        • [homes]
        • tunefs.ocfs2
        • vgchange
        • vgcreate
        • HKLM\Software\Samba
        • LDIF (LDAP Data Interchange Format)
        • Microsoft-ADSI-Edit
        • Microsoft-LDP
        • microsoft mmc
        • Microsoft RSAT Tools
        • Microsoft Regedit
        • REG_SZ and REG_MULTI_SZ
        • SeDiskOperatorPrivilege
        • vgdisplay
        • Virtual Machine Generation Identifier
        • Virtual Machine Snapshots
        • allow-dns-updates
        • vgreduce
        • vgreduce
        • vgreduce
        • chmod
        • chown
        • cifscreds
        • cifsiostat
        • config backend
        • vgreduce
        • create-mask and create-mode
        • ifenslave
        • log level (or debuglevel) in Samba
        • delete veto files
        • dig
        • Directory Mask and Force Directory Mode
        • dns-forwarder
        • /etc/exports
        • /etc/fstab
        • /etc/group
        • /etc/idmapd.conf
        • ip
        • /etc/nsswitch.conf
        • /etc/pam.conf
        • /etc/pam.d/
        • /etc/group
        • /etc/resolv.conf
        • exportfs
        • ipvsadm
        • force-create-mode
        • force-directory-mode
        • force group
        • force-user
        • getcifsacl
        • getent
        • getfacl
        • getfattr
        • gpupdate
        • keepalived-configuration-file
        • kpartx
        • ldirectord-configuration-file
        • loadbalancing-algorithms
        • lvchange
        • lvconvert
        • host
        • lvcreate
        • lvdisplay
        • idmap-config
        • idmap_ad
        • lvextend
        • idmap_ldap
        • idmap_rfc2307
        • idmap_rid
        • idmap_tdb
        • idmap_tdb2
        • include
        • inherit-acls
        • lvreduce
        • FreeIPA (IPA)
        • ipa
        • ipa
        • IPA
        • ipa-adtrust-install
        • ipa-advice
        • ipa-client-install
        • ipa-replica-install
        • ipa-replica-prepare
        • ipa-server-install
        • ipactl
        • ipctl
        • kdestroy
        • kinit
        • klist
        • krb5.conf
        • lvresize
        • ldbadd
        • ldbdel
        • ldbedit
        • ldbmodify
        • ldbsearch
        • libnss_winbind
        • libpam_winbind
        • mdadm
        • log level (or debuglevel) in Samba
        • logon-path
        • logon-script
        • map-acl-inherit
        • mount
        • mount.cifs
        • mount Command
        • mkfs.gfs2
        • mkfs.ocfs2
        • multicast dns register
        • net
        • monit
        • net ads
        • net registry
        • nfs4_editfacl
        • nfs4_getfacl
        • nfs4_setfacl
        • nmbd (NetBIOS Name Service Daemon)
        • ntpd.conf
        • ntpsigndsocket
        • mount.gfs2
        • mount.ocfs2
        • mounted.ocfs2
        • multipath
        • nmcli
        • pam_mount.conf.xml
        • pam_mount.so
        • pam_smbpass.so
        • nvme-cli
        • passdb-backend
        • o2image
        • pdbedit
        • o2info
        • ocfpacemakerHealthCPU
        • ocfpacemakerHealthSMART
        • profile-acls
        • rdesktop
        • ocfpacemakerNodeUtilization
        • realm
        • Registry shares
        • registry.tdb in Samba
        • robocopy
        • ocfpacemakerocfSysInfo
        • rpcclient
        • rsync.conf
        • rsync
        • samba regedit
        • samba-tool dbcheck
        • samba-tool dns
        • ocfpacemakerping
        • samba-tool domain backup
        • samba-tool domain backup
        • samba-tool domain exportkeytab
        • samba-tool domain passwordsettings
        • pcs
        • pvcreate
        • samba-tool gpo
        • samba-tool group
        • samba-tool ntacl
        • pvdisplay
        • samba-tool spn
        • samba-tool user
        • Samba
        • samba_dnsupdate
        • secrets.tdb in Samba
        • security
        • server role
        • server services
        • server string
        • setcifsacl
        • setfacl
        • sharesec
        • smb-encrypt
        • smb.conf
        • smbcacls
        • smbclient
        • smbcontrol
        • smbcquotas
        • smbd (Samba Daemon)
        • smbget
        • smbpasswd
        • pvmove
        • smbstatus
        • smbtar
        • pvremove
        • pvresize
        • sss_cache
        • sss_debuglevel
        • sss_override
        • sss_user and sss_group
        • sssd.conf
        • rados-(including-relevant-subcommands)
        • store-dos-attributes
        • systemctl
        • tdbbackup
        • tdbdump
        • tdbrestore
        • tdbtool
        • template-homedir
        • template-shell
        • testparm
        • tls-cafile
        • tls-certfile
        • tls-dh-params-file
        • tls-enabled
        • tls-keyfile
        • rdb(including-relevant-subcommands)
        • /var/lib/samba/sysvol/
        • /var/lib/sss/db
        • /var/log/samba/
        • sbd
        • smartctl
        • vfs objects
        • vfs_acl_tdb
        • vfs_acl_xattr
        • wbinfo
        • winbind-enumerate-groups
        • smartd
        • winbind-offline-logon
        • winbind-separator
        • winbindd
        • workgroup
        • stonith
        • stonith_admin
      • LPIC3-303
        • /etc/aide/aide.conf
        • /etc/crypttab
        • /etc/openvas/
        • /etc/openvpn/
        • /etc/raddb/
        • /etc/rkhunter.conf
        • /etc/security/limits.conf
        • /etc/selinux/
        • /etc/snort
        • /etc/ssh/sshd_config
        • /etc/ssh
        • /etc/strongswan.conf
        • /etc/strongswan.d/.
        • /etc/swanctl/
        • /etc/swanctl/swanctl.conf
        • /etc/sysctl.conf
        • /etc/usbguard/rules.conf
        • /etc/usbguard/usbguard-daemon.conf
        • /etc/wireguard/
        • /proc/cgroups
        • nginx
        • slapd
        • ARP and NDP
        • Brute force attacks
        • Buffer overflows
        • CRL (Certificate Revocation List)
        • CSR (Certificate Signing Request)
        • CSRF
        • XSS
        • DoS and DDoS
        • keylogger
        • Link layer address and IP address spoofing
        • Man-in-the-Middle
        • OCSP (Online Certificate Status Protocol)
        • OpenSSL Configuration
        • PEM, DER, PKCS
        • Phishing
        • Privilege escalation
        • Rainbow tables
        • Rogue access points, routers, and DHCP servers
        • Rootkits
        • SQL and codes injection
        • Social engineering
        • slapindex
        • varlibldap
        • aide
        • apol
        • audit.rules
        • audit2allow
        • audit2why
        • auditctl
        • auditd.conf
        • auditd
        • ausearch, aureport
        • -sys-fs-group-
        • capsh
        • chcon
        • chkrootkit
        • chroot
        • conf.maldet
        • cryptmount
        • cryptsetup (Disk Encryption Setup)
        • delv
        • dnssec-dsfromkey
        • -sys-fs-group
        • dnssec-settime
        • Trojans
        • dpkg
        • ecryptfs- commands
        • ecryptfsd
        • fixfiles
        • getcap
        • getenforce
        • getfacl
        • getfattr
        • getsebool
        • grub.cfg
        • httpd.conf (Apache HTTP Server Configuration)
        • ip6tables-restore
        • ip6tables-save
        • ip6tables
        • ipset
        • iptables-save
        • iptables
        • Kismet
        • Linux Malware Detect (maldet)
        • mod_ssl (Apache SSL Module)
        • mount.ecryptfs, umount.ecryptfs
        • named.conf
        • ndpmon
        • newrole
        • ntop
        • openssl
        • openvas-adduser
        • openvas-feed-update
        • openvas-mkcert
        • openvas-nvt-sync
        • openvas-rmuser
        • openvassd
        • OpenVPN
        • pam_ecryptfs
        • pam_limits.so
        • pam_tty_audit.so
        • pulledpork.pl
        • radclient
        • radiusd.conf
        • radiusd
        • Viruses
        • radmin
        • radtest
        • radwho
        • restorecon
        • rkhunter
        • rndc
        • c
        • seaudit
        • seinfo
        • selinuxenabled
        • semanage
        • sestatus
        • setcap
        • setcon
        • setenforce
        • setfacl
        • setfattr
        • setfiles
        • setsebool
        • snort-stat
        • snort
        • ssh-keygen
        • swanctl
        • sysctl
        • systemctl
        • systemd-cgls
        • systemd-cgtop
        • Tcpdump
        • togglesebool
        • tshark
        • dnssec-keygen
        • usbguard
        • wg-quick
        • wg
        • wireshark
        • ~/.ssh/
      • LPIC3-305
        • -dev-kvm-
        • /etc/docker/daemon.json
        • /etc/libvirt — Libvirt Configuration Directory
        • -proc -[0-9]+-status
        • -proc-[0-9]+-ns
        • -sys-fs-cgroups
        • /var/lib/cloud
        • /var/lib/docker
        • CPU-flags
        • Dockerfile
        • Domain0(Dom0),DomainU (DomU)
        • Emulation and Simulation
        • Hardware Virtual Machine (HVM)
        • IaaS, PaaS, SaaS
        • Kernel-modules-kvm,kvm-intel.and.kvm-amd
        • Migration (P2V, V2V)
        • OpenStack
        • PV-DomU,HVM-DomU
        • Paravirtualization (PV)
        • QEMU Monitor
        • Terraform
        • Vagrantfile
        • brctl — Bridge Control Utility
        • capsh
        • cloud-init
        • syncd
        • dockerd
        • etc-xen-
        • guestumount — Virtual Disk Image Unmounting Tool
        • guestmount
        • guestumount
        • Hypervisor
        • ip(including-relevant-subcommands)
        • ip — Network Management Command
        • libvirtd — Libvirt Daemon (Legacy Central Virtualization Daemon)
        • LXC (Linux Containers)
        • LXD (Linux Container Daemon)
        • nsenter
        • Packer
        • tunefs.ocfs2
        • qemu-img — QEMU Disk Image Utility
        • vgchange
        • qemu — Quick Emulator
        • tunctl — TUN/TAP Device Control Utility
        • unshare
        • user-data
        • vagrant
        • virsh — Virtualization Shell for Managing VMs
        • virt-cat
        • virt-copy-in
        • virt-copy-out
        • virt-df
        • virt-diff
        • virt-filesystems
        • virt-inspector
        • virt-p2v-make-disk
        • virt-p2v
        • virt-rescue
        • virt-resize
        • virt-sparsify
        • virt-sysprep
        • virt-v2v
        • xentop
        • xl.cfg
        • xl.conf
        • xl
      • LPIC3-306
        • /etc/drbd.conf
        • /etc/drbd.d/
        • /etc/lvm/lvm.conf Configuration File
        • /etc/multipath.conf
        • /etc/network/interfaces
        • /etc/smartd.conf
        • /etc/sysconfig/networking-scripts/ifcfg-*
        • /etc/systemd/network/*.netdev
        • /etc/systemd/network/*.network
        • /proc/drbd
        • /proc/mdstat
        • /proc/sys/dev/raid
        • -sys-class-net-bond-bonding-miimon
        • -sys-class-net-bond-bonding-slaves
        • -sys-class-net-bonding_masters
        • Access Control Lists (ACLs)
        • Active-Active Cluster
        • vgcreate
        • Cluster Services
        • Disaster Recovery (DR)
        • Failover Cluster
        • Fencing (Node and Resource Level Fencing)
        • HAProxy Configuration File
        • LVS Forwarding Methods
        • Load-Balanced Cluster
        • Mean Time Before Failure (MTBF)
        • Mean Time To Repair (MTTR)
        • Primary, Secondary
        • ProtocolA,BandC
        • Quorum
        • Redundancy
        • Replication
        • Service-Level Agreement (SLA)
        • Session-Handling
        • Shared-Disk Cluster
        • Shared-Nothing Cluster
        • Split-Brain
        • State-Handling
        • Three-way replication
        • active-passive-cluster
        • apctest
        • apcupsd
        • authkeys
        • bonding.ko
        • Ceph
        • ceph-authtool
        • ceph-bluestore-tool
        • ceph-deploy
        • ceph-volume
        • ceph.conf
        • CephFS
        • cibadmin
        • connection-scheduling-algorithms
        • corosync-cfgtool
        • corosync-cmapctl
        • corosync-quorumtool
        • corosync.conf
        • crm
        • crm_attribute
        • crm_mon
        • crm_node
        • crm_resource
        • crm_shadow
        • crm_simulate
        • crm_standby
        • crm_verify
        • crushtool
        • DRBD Kernel Module
        • drbdadm
        • drbdmeta
        • drbdsetup
        • vgdisplay
        • fsck.ocfs2
        • genhash
        • gfs2_edit
        • gfs2_grow
        • gfs2_jadd
        • gluster
        • ifenslave Command
        • ip Command
        • ipvsadm
        • iscsiadm
        • iscsid.conf
        • Keepalived Configuration File
        • kpartx
        • ldirectord Configuration File
        • loadbalancing-algorithms
        • vgreduce
        • lvconvert
        • lvcreate
        • lvdisplay
        • lvextend
        • lvreduce
        • lvresize
        • mdadm
        • mkfs.gfs2
        • mkfs.ocfs2
        • Monit
        • mount.gfs2
        • mount.ocfs2
        • mounted.ocfs2
        • multipath
        • nmcli
        • nvme-cli
        • o2image
        • o2info
        • ocf:pacemaker:HealthCPU
        • ocf:pacemaker:HealthSMART
        • ocf:pacemaker:NodeUtilization
        • ocf:pacemaker:ocfSysInfo
        • ocf:pacemaker:ping
        • pcs
        • pvcreate
        • pvdisplay
        • pvmove
        • pvremove
        • pvresize
        • rados
        • rbd
        • authkey
        • smartctl
        • smartd
        • bonding.ko-(including-relevant-module-options)
        • stonith
        • stonith_admin
        • syncd
        • targets.conf
        • tgtadm
        • tunefs.ocfs2
        • vgchange
        • vgcreate
        • vgdisplay
        • vgreduce
  • Security attacks full list
Powered by GitBook
On this page
  • Command Information
  • Command History
  • Navigating Directories
  • Creating Directories
  • Moving Directories
  • Deleting Directories
  • Creating Files
  • Standard Output, Standard Error and Standard Input
  • Moving Files
  • Deleting Files
  • Reading Files
  • Sorting Files
  • File Permissions
  • Finding Files
  • Find in Files
  • Symbolic Links
  • Compressing Files
  • Decompressing Files
  • Packages
  • Disk Usage
  • Memory Usage
  • Shutdown and Reboot
  • Identifying Processes
  • Process Priority
  • Killing Processes
  • Date & Time
  • Scheduled Tasks
  • User Management
  • HTTP Requests
  • Network Troubleshooting
  • DNS
  • Hardware
  • System Information
  • Terminal Multiplexers
  • Secure Shell Protocol (SSH)
  • Secure Copy
  • Bash Profile

Quick review for commands

PreviousLinux CommandsNextConfig file parameters you can use

Last updated 1 year ago

Contents

Command Information

man chmod                   # Display page manual of a command
man -f|--whatis chmod       # Display short description about a command
man -k|--apropos permission # Display all related commands from a specific keyword

chmod --help                # Display usage options of a command

Command History

history                                # View all previous commands
history | grep saman                   # View the commands using a specific word
history | grep -E|--extended-regexp -i|--ignore-case 'saman1|saman2|saman3' # View the commands using more than 1 specific word(case sensitive)
history | head -n|--lines 3            # View the first 3 executed commands
history 3                              # View the last 3 executed commands
history -d 99                          # Clear a command from a specific line 
history -c                             # Clears all history commands
!!                                     # Run the last command executed

touch saman.sh                         # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<┐
chmod +x !$                            # !$ is the last argument of the last command i.e. saman.sh <<<<┘

Navigating Directories

pwd                       # Print current directory path
ls                        # List directories
ls -a|--all               # List directories including hidden
ls -l                     # List directories in long form
ls -l -h|--human-readable # List directories in long form with human readable sizes
ls -t                     # List directories by modification time, newest first
stat saman.txt            # List size, created and modified timestamps for a file
stat saman                # List size, created and modified timestamps for a directory
tree                      # List directory and file tree
tree -a                   # List directory and file tree including hidden
tree -d                   # List directory tree

cd saman                  # Go to saman sub-directory
cd                        # Go to home directory
cd ~                      # Go to home directory
cd -                      # Go to the previously chosen directory
pushd saman               # Go to saman sub-directory and add previous directory to stack
popd                      # Go back to directory in stack saved by `pushd`

Creating Directories

mkdir saman                        # Create a directory
mkdir saman bar                    # Create multiple directories
mkdir -p|--parents saman/bar       # Create nested directory
mkdir -p|--parents {saman,bar}/baz # Create multiple nested directories

mktemp -d|--directory              # Create a temporary directory

Moving Directories

cp -R|--recursive saman bar                              # Copy directory
mv saman bar                                             # Move directory

rsync -z|--compress -v|--verbose /saman /bar             # Copy directory, overwrites destination
rsync --ignore-existing -a|--archive -z|--compress -v|--verbose /saman /bar # Copy directory, without overwriting destination
rsync -avz /saman username@hostname:/bar                 # Copy local directory to remote directory
rsync -avz username@hostname:/saman /bar                 # Copy remote directory to local directory

Deleting Directories

rmdir saman                        # Delete non-empty directory
rm -r|--recursive saman            # Delete directory including contents
rm -r|--recursive -f|--force saman # Delete directory including contents, ignore nonexistent files and never prompt

Creating Files

touch saman.txt          # Create file or update existing files modified timestamp
touch saman.txt bar.txt  # Create multiple files
touch {saman,bar}.txt    # Create multiple files
touch test{1..3}         # Create test1, test2 and test3 files
touch test{a..c}         # Create testa, testb and testc files

mktemp                   # Create a temporary file

Standard Output, Standard Error and Standard Input

echo "saman" > bar.txt     # Overwrite file with content
echo "saman" >> bar.txt    # Append to file with content

ls exists 1> stdout.txt    # Redirect the standard output to a file
ls noexist 2> stderror.txt # Redirect the standard error output to a file
ls > out.txt 2>&1          # Redirect standard output and error to a file
ls > /dev/null             # Discard standard output and error

read saman                 # Read from standard input and write to the variable saman

Moving Files

cp saman.txt bar.txt                                 # Copy file
mv saman.txt bar.txt                                 # Move file

rsync -z|--compress -v|--verbose /saman.txt /bar     # Copy file quickly if not changed
rsync -z|--compress -v|--verbose /saman.txt /bar.txt # Copy and rename file quickly if not changed

Deleting Files

rm saman.txt            # Delete file
rm -f|--force saman.txt # Delete file, ignore nonexistent files and never prompt

Reading Files

cat saman.txt              # Print all contents
less saman.txt             # Print some contents at a time (g - go to top of file, SHIFT+g, go to bottom of file, /saman to search for 'saman')
head saman.txt             # Print top 10 lines of file
tail saman.txt             # Print bottom 10 lines of file
tail -f|--follow saman.txt # Print bottom 10 lines of file updating with new data
open saman.txt             # Open file in the default editor
wc saman.txt               # List number of lines words and characters in the file

Sorting Files

sort saman.txt                                  # Sort file (ascending order) 
sort -r|--reverse saman.txt                     # Sort file (descending order) 
sort -n|--numeric-sort saman.txt                # Sort numbers instead of strings 
sort -t|--field-separator: -k 3n /saman/saman.txt # Sort by the third column of a file

File Permissions

#
Permission
rwx
Binary

7

read, write and execute

rwx

111

6

read and write

rw-

110

5

read and execute

r-x

101

4

read only

r--

100

3

write and execute

-wx

011

2

write only

-w-

010

1

execute only

--x

001

0

none

---

000

For a directory, execute means you can enter a directory.

User
Group
Others
Description

6

4

4

User can read and write, everyone else can read (Default file permissions)

7

5

5

User can read, write and execute, everyone else can read and execute (Default directory permissions)

  • u - User

  • g - Group

  • o - Others

  • a - All of the above

ls -l /saman.sh            # List file permissions
chmod +100 saman.sh        # Add 1 to the user permission
chmod -100 saman.sh        # Subtract 1 from the user permission
chmod u+x saman.sh         # Give the user execute permission
chmod g+x saman.sh         # Give the group execute permission
chmod u-x,g-x saman.sh     # Take away the user and group execute permission
chmod u+x,g+x,o+x saman.sh # Give everybody execute permission
chmod a+x saman.sh         # Give everybody execute permission
chmod +x saman.sh          # Give everybody execute permission

Finding Files

Find binary files for a command.

type -a wget                              # Display all locations of executable
which -a wget                             # Display all locations of executables 
whereis wget                              # Find the binary, source, and manual page files

locate uses an index and is fast.

updatedb                                   # Update the index

locate saman.txt                             # Find a file
locate --ignore-case                       # Find a file and ignore case
locate f*.txt                              # Find a text file starting with 'f'

find doesn't use an index and is slow.

find /path -name saman.txt                   # Find a file
find /path -iname saman.txt                  # Find a file with case insensitive search
find /path -name "*.txt"                   # Find all text files
find /path -name saman.txt -delete           # Find a file and delete it
find /path -name "*.png" -exec pngquant {} # Find all .png files and execute pngquant on it
find /path -type f -name saman.txt           # Find a file
find /path -type d -name saman               # Find a directory
find /path -type l -name saman.txt           # Find a symbolic link
find /path -type f -mtime +30              # Find files that haven't been modified in 30 days
find /path -type f -mtime +30 -delete      # Delete files that haven't been modified in 30 days

Find in Files

grep 'saman' /bar.txt                         # Search for 'saman' in file 'bar.txt'
grep 'saman' /bar -r|--recursive              # Search for 'saman' in directory 'bar'
grep 'saman' /bar -R|--dereference-recursive  # Search for 'saman' in directory 'bar' and follow symbolic links
grep 'saman' /bar -l|--files-with-matches     # Show only files that match
grep 'saman' /bar -L|--files-without-match    # Show only files that don't match
grep 'saman' /bar -i|--ignore-case            # Case insensitive search
grep 'saman' /bar -x|--line-regexp            # Match the entire line
grep 'saman' /bar -C|--context 1              # Add N line of context above and below each search result
grep 'saman' /bar -v|--invert-match           # Show only lines that don't match
grep 'saman' /bar -c|--count                  # Count the number lines that match
grep 'saman' /bar -n|--line-number            # Add line numbers
grep 'saman' /bar --colour                    # Add colour to output
grep 'saman\|bar' /baz -R                     # Search for 'saman' or 'bar' in directory 'baz'
grep --extended-regexp|-E 'saman|bar' /baz -R # Use regular expressions
grep -E 'saman|bar' /baz -R                   # Use regular expressions

Replace in Files

sed 's/fox/bear/g' saman.txt                          # Replace fox with bear in saman.txt and output to console
sed 's/fox/bear/gi' saman.txt                         # Replace fox (case insensitive) with bear in saman.txt and output to console
sed 's/red fox/blue bear/g' saman.txt                 # Replace red with blue and fox with bear in saman.txt and output to console
sed 's/fox/bear/g' saman.txt > bar.txt                # Replace fox with bear in saman.txt and save in bar.txt
sed -i|--in-place 's/fox/bear/g' saman.txt            # Replace fox with bear and overwrite saman.txt
sed -i|--in-place '/red fox/i\blue bear' saman.txt    # Insert blue bear before red fox and overwrite saman.txt
sed -i|--in-place '/red fox/a\blue bear' saman.txt    # Insert blue bear after red fox and overwrite saman.txt
sed -i|--in-place '10s/find/replace/' saman.txt       # Replace the 10th line of the file 
sed -i|--in-place '10,20s/find/replace/' saman.txt    # Replace in the file 10-20 lines 

File Editor

nano                              # Open a new file in nano
nano saman.txt                      # Open a specific file
nano -m|--mouse saman.txt           # Enable the use of the mouse
nano -l|--linenumbers saman.txt     # Show line numbers in front of the text
nano +line,10 saman.txt             # Open file positioning the cursor at the specified line and column
nano -B|--backup saman.txt          # Create a backup file (`saman~`) when saving edits

Symbolic Links

ln -s|--symbolic saman bar            # Create a link 'bar' to the 'saman' folder
ln -s|--symbolic -f|--force saman bar # Overwrite an existing symbolic link 'bar'
ls -l                               # Show where symbolic links are pointing

Compressing Files

zip

Compresses one or more files into *.zip files.

zip saman.zip /bar.txt                # Compress bar.txt into saman.zip
zip saman.zip /bar.txt /baz.txt       # Compress bar.txt and baz.txt into saman.zip
zip saman.zip /{bar,baz}.txt          # Compress bar.txt and baz.txt into saman.zip
zip -r|--recurse-paths saman.zip /bar # Compress directory bar into saman.zip

gzip

Compresses a single file into *.gz files.

gzip /bar.txt saman.gz           # Compress bar.txt into saman.gz and then delete bar.txt
gzip -k|--keep /bar.txt saman.gz # Compress bar.txt into saman.gz

tar -c

Compresses (optionally) and combines one or more files into a single *.tar, *.tar.gz, *.tpz or *.tgz file.

tar -c|--create -z|--gzip -f|--file=saman.tgz /bar.txt /baz.txt # Compress bar.txt and baz.txt into saman.tgz
tar -c|--create -z|--gzip -f|--file=saman.tgz /{bar,baz}.txt    # Compress bar.txt and baz.txt into saman.tgz
tar -c|--create -z|--gzip -f|--file=saman.tgz /bar              # Compress directory bar into saman.tgz

Decompressing Files

unzip

unzip saman.zip          # Unzip saman.zip into current directory

gunzip

gunzip saman.gz           # Unzip saman.gz into current directory and delete saman.gz
gunzip -k|--keep saman.gz # Unzip saman.gz into current directory

tar -x

tar -x|--extract -z|--gzip -f|--file=saman.tar.gz # Un-compress saman.tar.gz into current directory
tar -x|--extract -f|--file=saman.tar              # Un-combine saman.tar into current directory

Packages

apt update                          # Refreshes repository index
apt search wget                     # Search for a package
apt show wget                       # List information about the wget package
apt list --all-versions wget        # List all versions of the package
apt install wget                    # Install the latest version of the wget package
apt install wget=1.2.3              # Install a specific version of the wget package
apt remove wget                     # Removes the wget package
apt upgrade                         # Upgrades all upgradable packages
apt clean                           # Clears out the local repository of downloaded package files

dpkg -i|--install package_name.deb  # Install deb file
rpm -i|--install package_name.rpm   # Install rpm file 

Install package source code

tar zxvf sourcecode.tar.gz
cd sourcecode
./configure
make
make install

Disk Usage

df                     # List disks, size, used and available space
df -h|--human-readable # List disks, size, used and available space in a human readable format

du                     # List current directory, subdirectories and file sizes
du /saman/bar            # List specified directory, subdirectories and file sizes
du -h|--human-readable # List current directory, subdirectories and file sizes in a human readable format
du -d|--max-depth      # List current directory, subdirectories and file sizes within the max depth
du -d 0                # List current directory size

Memory Usage

free                   # Show memory usage
free -h|--human        # Show human readable memory usage
free -h|--human --si   # Show human readable memory usage in power of 1000 instead of 1024
free -s|--seconds 5    # Show memory usage and update continuously every five seconds

Shutdown and Reboot

shutdown                     # Shutdown in 1 minute
shutdown now                 # Immediately shut down
shutdown +5                  # Shutdown in 5 minutes

shutdown -r|--reboot         # Reboot in 1 minute
shutdown -r|--reboot now     # Immediately reboot
shutdown -r|--reboot +5      # Reboot in 5 minutes
shutdown -c                  # Cancel a shutdown or reboot

reboot                       # Reboot now
reboot -f                    # Force a reboot

Identifying Processes

top                    # List all processes interactively
htop                   # List all processes interactively
ps ax                  # List all processes
pidof saman              # Return the PID of all saman processes

CTRL+Z                 # Suspend a process running in the foreground
bg                     # Resume a suspended process and run in the background
fg                     # Bring the last background process to the foreground
fg 1                   # Bring the background process with the PID to the foreground

sleep 30 &             # Sleep for 30 seconds and move the process into the background
jobs                   # List all background jobs
jobs -p                # List all background jobs with their PID

lsof                   # List all open files and the process using them
lsof -itcp:4000        # Return the process listening on port 4000

Process Priority

Process priorities go from -20 (highest) to 19 (lowest).

nice -n -20 saman        # Change process priority by name
renice 20 PID          # Change process priority by PID
ps -o ni PID           # Return the process priority of PID

Killing Processes

CTRL+C                 # Kill a process running in the foreground
kill PID               # Shut down process by PID gracefully. Sends TERM signal.
kill -9 PID            # Force shut down of process by PID. Sends SIGKILL signal.
pkill saman              # Shut down process by name gracefully. Sends TERM signal.
pkill -9 saman           # force shut down process by name. Sends SIGKILL signal.
killall saman            # Kill all process with the specified name gracefully.

Date & Time

date                            # Print the date and time
date --iso-8601                 # Print the ISO8601 date
date --iso-8601=ns              # Print the ISO8601 date and time

date -s "02 DEC 2020 12:02:02"  # Manually change date and time
dpkg-reconfigure tzdata         # Change date/timezone

uptime                          # Print how long the system has been running
time tree                       # Print amount of time to tree takes to execute

Scheduled Tasks

   *      *         *         *           *
Minute, Hour, Day of month, Month, Day of the week
crontab -l                 # List cron tab
crontab -e                 # Edit cron tab in a file editor
crontab /path/crontab      # Load cron tab from a file
crontab -l > /path/crontab # Save cron tab to a file

* * * * * saman              # Run saman every minute
*/15 * * * * saman           # Run saman every 15 minutes
0 * * * * saman              # Run saman every hour
15 6 * * * saman             # Run saman daily at 6:15 AM
44 4 * * 5 saman             # Run saman every Friday at 4:44 AM
0 0 1 * * saman              # Run saman at midnight on the first of the month
0 0 1 1 * saman              # Run saman at midnight on the first of the year

at -l                      # List scheduled tasks
at -c 1                    # Show task with ID 1
at -r 1                    # Remove task with ID 1
at now + 2 minutes         # Create a task in a file editor to execute in 2 minutes
at 12:34 PM next month     # Create a task in a file editor to execute at 12:34 PM next month
at tomorrow                # Create a task in a file editor to execute tomorrow

User Management

sudo su                                            # Switch to root user
sudo saman                                           # Execute commands(has permission denied) as the root user
sudo nano /saman/saman.txt                             # Open directories and files(is not writable) as the root user
su username                                        # Switch to a different user

passwd                                             # To change the password of a user
adduser username                                   # To add a new user
userdel username                                   # To remove user
userdel -r|--remove username                       # To remove user with home directory and mail spool
usermod -a|--append -G|--groups GROUPNAME USERNAME # To add a user to a group
deluser USER GROUPNAME                             # To remove a user from a group

last                                               # Display information of all the users logged in
last username                                      # Display information of a particular user
w                                                  # Display who is online

HTTP Requests

curl https://example.com                               # Return response body
curl -i|--include https://example.com                  # Include status code and HTTP headers
curl -L|--location https://example.com                 # Follow redirects
curl -O|--remote-name saman.txt https://example.com      # Output to a text file
curl -H|--header "User-Agent: saman" https://example.com # Add a HTTP header
curl -X|--request POST -H "Content-Type: application/json" -d|--data '{"saman":"bar"}' https://example.com # POST JSON
curl -X POST -H --data-urlencode saman="bar" http://example.com  # POST URL Form Encoded

wget https://example.com/file.txt                              # Download a file to the current directory
wget -O|--output-document saman.txt https://example.com/file.txt # Output to a file with the specified name

Network Troubleshooting

ifconfig                     # Display all network card and interface information 
ifconfig -a                  # Display information of all network cards (including those that are not started at boot) 
ifconfig eth0                # Display specific device information 
ifconfig eth0 up             # Turn on the network card
ifconfig eth0 down           # Turn off the network card
ifconfig eth0 192.168.120.56 # Configure IP address for network card

curl ifconfig.me             # Obtain external IP address

ping example.com             # Send multiple ping requests using the ICMP protocol
ping -c 10 -i 5 example.com  # Make 10 attempts, 5 seconds apart

ip addr                      # List IP addresses on the system
ip route show                # Show IP addresses to router
 
netstat -i|--interfaces      # List all network interfaces and in/out usage
netstat -l|--listening       # List all open ports

traceroute example.com       # List all servers the network traffic goes through

mtr -w|--report-wide example.com                                    # Continually list all servers the network traffic goes through
mtr -r|--report -w|--report-wide -c|--report-cycles 100 example.com # Output a report that lists network traffic 100 times

nmap 0.0.0.0                 # Scan for the 1000 most common open ports on localhost
nmap 0.0.0.0 -p1-65535       # Scan for open ports on localhost between 1 and 65535
nmap 192.168.4.3             # Scan for the 1000 most common open ports on a remote IP address
nmap -sP 192.168.1.1/24      # Discover all machines on the network by ping'ing them

DNS

dig example.com                 # Show query information of domain A records
dig -4 example.com              # Show IPv4 A records
dig -6 example.com              # Show IPv6 AAA records
dig example.com @nameserver     # Show query of a specific nameserver
dig example.com -p 123          # Show query of a specific port number

cat /etc/resolv.conf            # Nameservers file
cat /etc/systemd/resolved.conf  # DNS resolver config file

Hardware

lsusb                  # List USB devices
lspci                  # List PCI hardware
lshw                   # List all hardware

System Information

uname -s                  # Print kernel name
uname -r                  # Print kernel release
uname -m                  # Print Architecture
uname -o                  # Print Operating System
uname -a                  # Print all Systen info  

lsb_release -a            # Print distribution-specific information
dpkg --print-architecture # Print-architecture by name
 
cat /proc/cpuinfo         # Show cpu info
cat /proc/meminfo         # Show memory info

Terminal Multiplexers

Start multiple terminal sessions. Active sessions persist reboots. tmux is more modern than screen.

tmux             # Start a new session (CTRL-b + d to detach)
tmux ls          # List all sessions
tmux attach -t 0 # Reattach to a session

screen           # Start a new session (CTRL-a + d to detach)
screen -S saman    # Start a new named session
screen -ls       # List all sessions
screen -R 31166  # Reattach to a session

exit             # Exit a session
reset            # Reset the terminal(when binary and the terminal state is messed up)

Secure Shell Protocol (SSH)

ssh hostname                 # Connect to hostname using your current user name over the default SSH port 22
ssh -i saman.pem hostname      # Connect to hostname using the identity file
ssh user@hostname            # Connect to hostname using the user over the default SSH port 22
ssh user@hostname -p 8765    # Connect to hostname using the user over a custom port
ssh ssh://user@hostname:8765 # Connect to hostname using the user over a custom port

Set default user and port in ~/.ssh/config, so you can just enter the name next time:

$ cat ~/.ssh/config
Host name
  User saman
  Hostname 127.0.0.1
  Port 8765
$ ssh name

Secure Copy

scp saman.txt ubuntu@hostname:/home/ubuntu                  # Copy saman.txt into the specified remote directory
scp ubuntu@hostname:/home/ubuntu/saman.txt /C:\Users\Admin    # Copy saman.txt from the specified remote directory

Bash Profile

  • bash - .bashrc

  • zsh - .zshrc

# Always run ls after cd
function cd {
  builtin cd "$@" && ls
}

# Prompt user before overwriting any files
alias cp='cp --interactive'
alias mv='mv --interactive'
alias rm='rm --interactive'

# Always show disk usage in a human readable format
alias df='df -h'
alias du='du -h'

Conditional Statements

Boolean Operators

  • $saman - Is true

  • !$saman - Is false

Numeric Operators

  • -eq - Equals

  • -ne - Not equals

  • -gt - Greater than

  • -ge - Greater than or equal to

  • -lt - Less than

  • -le - Less than or equal to

  • -e saman.txt - Check file exists

  • -z saman - Check if variable exists

String Operators

  • = - Equals

  • == - Equals

  • -z - Is null

  • -n - Is not null

  • < - Is less than in ASCII alphabetical order

  • > - Is greater than in ASCII alphabetical order

If Statements

#!/bin/bash

[[
if [[$saman = 'bar']]; then
  echo 'one'
elif [[$saman = 'bar']] || [[$saman = 'baz']]; then
  echo 'two'
elif [[$saman = 'ban']] && [[$USER = 'bat']]; then
  echo 'three'
else
  echo 'four'
fi
]]

Inline If Statements

#!/bin/bash

[[ $USER = 'saman' ]] && echo 'yes' || echo 'no'

While Loops

#!/bin/bash

[
declare -i counter
counter=10
while [$counter -gt 2]; do
  echo The counter is $counter
  counter=counter-1
done
]

For Loops

#!/bin/bash

for i in {0..10..2}
  do
    echo "Index: $i"
  done

for filename in file1 file2 file3
  do
    echo "Content: " >> $filename
  done

for filename in *;
  do
    echo "Content: " >> $filename
  done

Case Statements

#!/bin/bash

echo "What's the weather like tomorrow?"
read weather
Command Information
Command History
Navigating Directories
Creating Directories
Moving Directories
Deleting Directories
Creating Files
Standard Output, Error and Input
Moving Files
Deleting Files
Reading Files
Sorting Files
File Permissions
Finding Files
Find in Files
Replace in Files
File Editor
Symbolic Links
Compressing Files
Decompressing Files
Packages
Disk Usage
Memory Usage
Shutdown and Reboot
Identifying Processes
Process Priority
Killing Processes
Date & Time
Scheduled Tasks
User Mangement
HTTP Requests
Network Troubleshooting
DNS
Hardware
System Information
Terminal Multiplexers
Secure Shell Protocol (SSH)
Secure Copy
Bash Profile