Linux terminal tips and tricks

Execute the last command !!

!!

for example, if we entered “apt install htop” without sudo, an error is returned indicating that “sudo” is required

apt install htop
sudo !!

Be careful if your last command was “poweroff” while you type !! and press Enter, you guessed it, the system will shutdown.

Not sure what the last team was? use the “history” command to check the last command and even further back

Team work in the background

To keep the command running in the background, use “Ctrl + Z”, use “fg” to bring it back

(fg: foreground)

eg

nano /etc/apt/sources.list
Ctrl + Z
# (Выполнить любые другие необходимые команды)

fg
# Теперь мы вернулись к nano

Cancel shutdown

# Если щелкнул выключение из графического интерфейса, используйте следующую команду для отмены
shutdown -c

# Если процедура выключения началась, используйте следующую команду для отмены
pkill shutdown

Execute a command at a specific time

We may need to install the “at” command first

# Debian / Ubuntu / Kali Linux и т. д.
sudo apt install at

# RHEL / CentOS / Fedora и т. д.
sudo dnf install at

в 01:20 Вт

poweroff

Ctrl + D

at -l: list all scheduled jobs for the current user in -r : delete a scheduled job, eg “at -r 1”

Sidebar