This repository contains a comprehensive guide to common Linux commands with examples and screenshots. It's designed to help users quickly reference essential commands for navigating, managing files, and configuring the system in a Linux environment.
- User Prompt
- PWD
- CD
- Date and Cal
- Hostnamectl
- LS Command
- Mkdir and Rmdir
- Init Commands
- Create File
- Overwrite or Create File (cat >)
root@localhost ~# Explanation
This prompt represents the following:
- root: You are logged in as the root user, which has full administrative privileges.
- localhost: The hostname is set to localhost, the default for systems without a unique name.
- ~: The home directory of the root user (
/root). - #: Indicates you are logged in as the root user (a
$would indicate a non-root user).
The pwd command prints the current working directory.
The cd command allows you to change directories.
The cd .. command takes you to the parent directory.
date: Displays the current system date and time.
- Example variants:
+%a,+%A,+%x,+%X,+%h,+%Hfor various formats.
cal: Displays a calendar in the terminal.
- View calendar for a specific year or past/future months.
Use hostnamectl to manage the system's hostname and related settings.
To set a new hostname, use hostnamectl set-hostname <hostname>.
then type bash or rebot system for refresh
The ls command lists directory contents.
The ls -l command shows detailed information about files and directories:
- File Permissions
- Number of Links
- Owner and Group
- File Size
- Last Modification Time
- File/Directory Name
Hidden Files:
To list hidden files, use ls -a.
-
mkdir: Creates directories.- Example:
mkdir -p j/k/lcreates nested directoriesj/k/l. - Example:
mkdir ab{1..10}creates directoriesab1,ab2, ...,ab10.
- Example:
-
rmdir: Removes directories (only empty directories).
where cd ../.. command in Linux is used to move up two levels in the directory structure from your current location
- remove the directory j and all its contents (including subdirectories and files)
where
- -r: This option stands for recursive removal. It tells rm to delete directories and their contents recursively, including all files and subdirectories inside j.
- -v: This option stands for verbose. It tells rm to display what it's doing, printing each file and directory it removes.
- -f: This option stands for force. It forces rm to remove files and directories without prompting for confirmation, even if the files are write-protected or if the directory is not empty.
-Remove all files and directories (including hidden ones, if .* is used) in the current directory.
init 0: Shuts down the system.init 6: Reboots the system.
Use commands to create files in Linux.
The cat > command allows you to create or overwrite a file and input text interactively.
- To exit and save, press
Ctrl+D. - note: use cat and less for read the content inside the file
This cheat sheet covers some of the most essential Linux commands to navigate the file system, manage files, and configure your system. For more advanced usage, consider exploring additional command-line resources and man pages.





















