Linux Cheat Sheet

Linux Cheat Sheet

Alias

Open the bash config file

sudo nano ~/.bashrc

Add your alias to the end of the file, for example:

alias ll="ls -lh"
alias cd..="cd .."

Restart your shell

List running services

systemctl list-units --type=service --state=running

Create command alias

Edit the shell config file

nano ~/.bashrc

Add the alias to the end of the file. This example allows you to use just ls to get a full ls -la output.

alias ls='ls la'

Restart the shell

source ~/.bashrc

Rename a directory

To rename a directory in Linux, you can use the mv command with the current directory name and the new directory name.

mv [current directory name] [new directory name]

Display all users

To display all the users who exist on the server and sort them by name, you can use the “cat” command to read the “/etc/passwd” file and then pipe the output to the “cut” and “sort” commands.

cat /etc/passwd | cut -d: -f1 | sort

List file including hidden

ls -la ~

Check status of Apache

systemctl status apache2

Show the OS release

lsb_release -a

apt-get error: repository suite error

error when using apt-get update; the suite has changed to oldstable and needs to be accepted before you can use it

Reading package lists... Done
E: Repository 'http://archive.raspberrypi.org/debian buster InRelease' changed its 'Suite' value from 'testing' to 'oldstable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

To accept the change to the suite value run the following command

sudo apt-get update --allow-releaseinfo-change
Last modified July 21, 2024: update (e2ae86c)