Day12 #90DaysOfDevOps Challenge

Linux Cheat-sheet.

Linux Cheat-sheet

⚡Linux:

⭐Basic Linux Command

hostnamectl

Get system information including, operating system, kernel, and release version.

date

Display the current system date and time.

hostname

Display the hostname of the system.

passwd

To change the password.

ifconfig

Display the IP and Mac Address of the system.

users, who, and w

Display currently logged-in users in the system.

top

Display all running processes.

ls

List all files and directories in the current working directory.

ls -al

List all files and directories including, hidden files and other information like permissions, size, and owner.

cd

Change the directory to the home directory.

cd ..

Change the directory to one level up.

touch filename

Create a file.

cat filename

Display the content of the file.

cat file1 file2 > file3

Combine two files named file1 and file2 and store the output in a new file file3.

tail filename

Display the last 10 lines of a file.

head filename

Display the first 10 lines of a file.

mv oldfile newfile

Rename a file.

rm filename

Delete a file.

mkdir dirname

Create a directory.

rm -rf dirname

Remove a directory.

rmdir

Remove the empty directory.

pwd

To see the current working directory.

history

Print a history list of all commands.

clear

Clear the terminal.

shutdown -h now

Shut down the system.

reboot

Restart the system.

⭐File Permission Commands

ls -l filename

Check the current permission of any file.

chmod 777 filename

Assign full(read, write, and execute) permission to everyone.

chmod -R 777 dirname

Assign full permission to the directory and all sub-directories.

chmod 766 filename

Assign full permission to the owner, and read and write permission to the group and others.

chmod -x filename

Remove the execution permission of any file.

chown username filename

Change the ownership of a file.

chown user:group filename

Change the owner and group ownership of a file.

chown -R user:group dirname

Change the owner and group ownership of the directory and all sub-directories.

⭐User and Group Management commands

id

Display the UID and GID of the current user.

useradd username

Add a new user account.

userdel -r username

Delete a user account.

usermod [option] username

Change the user account information including, group, home directory, shell, and expiration date.

usermod -aG groupname username

Add a user to a specific group.

groupadd groupname

Create a new group.

groupdel groupname

Remove a group.

last

Display information of the last login user.

⭐Package Management Commands

apt-get install packagename

Install the package on Debian-based distributions

apt-get remove packagename

Remove a package on Debian-based distributions

apt-get upgrade packagename

Upgrade a specific package on Debian-based distributions

apt-get autoremove

Remove all unwanted packages on the Debian-based distribution

yum install packagename

Install the package on RPM-based distributions

yum remove packagename

Remove a package on RPM-based distributions

yum update

Update all system packages to the latest version on RPM-based distributions

yum list --installed

List all installed packages on RPM-based distributions

yum list --available

List all available packages on RPM-based distributions

⭐Vi Editor


Thank you for reading!📘