- Switch user command, allows to run commands with another users privileges, by default the root user:
su
Note
More on su
command:
- 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
- Get system architecture:
uname -a
- Get cpu info:
sudo vim /proc/cpuinfo
- Get memory info:
free
Note
More on free
command:
- Get disk info:
df
- Display processes:
top
# Or
vmstat
Note
More on top
command:
More on vmstat
command:
- Get boot info:
who -b
# to get uptime in yyyy-mm-dd HH:MM:SS format
uptime -s
Note
More on who
command:
More on uptime
command:
- 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
Note
More on users
command:
More on w
command:
- Show routing, network devices, interfaces and tunnels:
ip --color a
# Or, specifically for interfaces
vim /etc/network/interfaces
Note
More on ip
command:
More on /etc/network
file format:
- Check all system sockets:
ss -tunlp
- Check if there is a
GUI
installed:
ls /usr/bin/*session
Note
More on session
file format:
- 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:
- 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>
- 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
- 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