Skip to content

Latest commit

 

History

History
355 lines (280 loc) · 5.52 KB

COMMANDS.md

File metadata and controls

355 lines (280 loc) · 5.52 KB

Commands Glossary

System Commands

  • Switch user command, allows to run commands with another users privileges, by default the root user:
su

  • Control the systemd system and service manager:
systemctl
  • Shutdown the VM:
systemctl poweroff
  • Reboot the VM
systemctl reboot
  • Change hostname:
sudo hostnamectl set-hostname <hostname>
# And then change old user name to new one in:
sudo vim /etc/hosts
# and also
sudo vim /etc/hostname
# Reboot to apply changes
sudo reboot hostnamectl
  • Get system login password policy file:
sudo vim /etc/login.defs

Note

More on login.defs file format and configuration:

  • Get user's password policy:
sudo vim /etc/pam.d/common-password

Note

More on PAM configuration files:

  • Get system architecture:
uname -a
  • Get cpu info:
sudo vim /proc/cpuinfo
  • Get memory info:
free
  • Get disk info:
df
  • Display processes:
top
# Or
vmstat
  • Get boot info:
who -b
# to get uptime in yyyy-mm-dd HH:MM:SS format
uptime -s
  • List information about all available block devices:
lsblk
  • Check users information:
# print the user names of users currently logged in to the current host
users
# Show who is logged on and what they are doing.
w
  • Show routing, network devices, interfaces and tunnels:
ip --color a
# Or, specifically for interfaces
vim /etc/network/interfaces
  • Check all system sockets:
ss -tunlp
  • Check if there is a GUI installed:
ls /usr/bin/*session

cron Commands

  • Get system's crontab:
crontab -u root -e
  • Stop cron:
sudo /etc/init.d/cron stop
  • Start cron:
sudo /etc/init.d/cron start

Note

More on crontab command:

More on crontab file format:

More on cron System Administration service:


ufw Commands

  • Start ufw:
sudo ufw enable
  • Stop ufw:
sudo ufw disable
  • Get ufw status:
sudo ufw status
  • Open a port:
sudo ufw allow <port>
  • Close a port:
sudo ufw delete <port>

sudo Commands

  • Run an interactive login shell with root user's environment:
sudo -i

![Note]

  • Is the same as running su -
  • Check sudo's version and other stats:
sudo -V
# or
dpkg -s sudo | grep Status
  • Create a new user:
sudo adduser <username>
  • Remove a user:
sudo deluser <username>
  • Change a user's password:
sudo passwd <username>
  • Create a new group:
sudo addgroup <groupname>
  • Add a user to a group:
sudo adduser <username> <group>
  • Get PAM password policy:
sudo vim /etc/pam.d/common-password
  • Get sudo_config policy file:
sudo vim /etc/sudoers.d/sudo_config
  • Get sudo log file:
sudo vim /var/log/sudo/sudo_config
  • Get the system's journal
journalctl

ssh Commands

  • Get hostname:
hostname -I
  • Connect to a remote host:
ssh -p <port> <username>@<hostname>
  • Disconnect from a remote host:
exit
  • Get OpenSSH server process config:
vim /etc/ssh/sshd_config
  • Get ssh system-wide config:
vim /etc/ssh/ssh_config
  • Restart the OpenSSH service:
sudo systemctl restart ssh
  • Get ssh service status:
sudo service sshd status