Fundamentals Of Linux - All In One Linux Commands Cheatsheet
- Beginner's Guide To Linux
What Is Linux?
Linux is a free and open-source operating system that is widely used in computers, servers, and other devices. It was created by Linus Torvalds in 1991 as a Unix-like system that is highly customizable and can be modified by users to suit their specific needs.
Features Of Linux:
Linux has several features that make it a popular operating system, including:
Open-source: Linux is free and open-source, meaning that the source code is available for users to modify and distribute.
Stability: Linux is known for its stability, and it rarely crashes or freezes.
Security: Linux is inherently secure and is less vulnerable to viruses and malware compared to other operating systems.
Customizability: Linux can be customized to suit the specific needs of users and can be modified to run on a wide range of hardware.
Multi-user capability: Linux can support multiple users simultaneously, each with their login credentials and settings.
Command-line interface: Linux offers a powerful command-line interface that allows users to perform tasks efficiently and quickly.
Package management: Linux has a package management system that makes it easy to install, update, and remove the software.
Compatibility: Linux can run on a wide range of devices, including desktop computers, servers, mobile devices, and embedded systems.
Performance: Linux is highly efficient and can run on older or less powerful hardware, making it a popular choice for servers and embedded systems.
Community support: Linux has a large and active community of users and developers who provide support, guidance, and resources for users.
Linux Architecture In Brief:
The Linux architecture consists of three main components: the kernel, system libraries, hardware layer, and system and shell function.
Kernel: The kernel is the core of the operating system and manages system resources such as memory, CPU, and I/O devices. In other words, we can say it is the heart of Linux which directly communicate with hardware to perform file management, system, and security operations.
System Libraries: A set of library functions may be specified as these functions. These functions are implemented by the operating system and do not require code access rights on the kernel modules.
Hardware layer: The hardware layer of Linux is made up of several peripheral devices such as a CPU, HDD, and RAM.
Shell: A Shell in Linux is the terminal or the interface between the user and kernel. A user provides commands understood by the kernel using the shell.
Some of the major Linux distributions are Debian, Ubuntu, RHEL, CentOS, Linux Mint, AIX, Kali Linux, etc.
Let's Talk About The Basic Commands You can Start With Linux:
In Linux, everything is a file including a hardware program. All the files are stored in a directory that comprises a tree structure. It is called File System Hierarchy.
Therefore, everything in Linux starts with "/". It is known as the root directory.
~ is your Home directory
Here are some basic Linux commands and their uses:
pwd
: Displays the current working directory.ls
: Lists the contents of a directory.cd
: Changes the current working directory.mkdir
: Creates a new directory.rmdir
: Deletes an empty directory.touch
: Creates a new empty file or updates the modification time of an existing file.cp
: Copies a file or directory.mv
: Moves a file or directory.rm
: Removes a file or directory.cat
: Displays the contents of a file.grep
: Searches for a pattern in a file.ps
: Displays information about running processes.kill
: Sends a signal to a process to terminate it.sudo
: Runs a command with superuser privileges.man
: Displays the manual page for a command.
Let's See How To Use These Commands:
#Create Directory
To create a single directory use
#mkdir /devops
To create multiple directories use
#mkdir batman superman disney
To create a directory(folder in windows) path (a directory inside a directory) use
#mkdir -p food/Italian/mexican/indian
To create a sequential number of directories #mkdir class{1..10}
#CD: Change Directory
cd command is used to change the directory
#pwd: present working directory
pwd command shows the current directory you are in.
Touch:
The touch command is used for creating an empty file, we can’t write, edit or save data in a file.
Create a single file with the touch command
#touch books
Create multiple files
#touch maths physics english
Create several files
#touch subject{1..10}
Cat:
cat command is used to view the content of the file.
To view the content of the single file "$cat filename"
Files and Directory Permissions In Linux:
rwx refers to read (4), write (2), execute (1).
In linux permissions are given to :
owner (user): permission used for the user/owner of the file
Group: Permissions used by the member of the group
Other:Permissions used by all other users
Commands Used To Modify The Permissions:
chmod
- change/modify the permissions
chmod -r
change the permissions of a directory
chmod a +rwx myfile
Allow all users to read, write or execute my file
chmod go -r myfile
Remove read permission from the group and others.
chown A filename
Change ownership of a file to user A.
Exmple : Modifying permissions of books file:
#Removing A Directory Folder:
rmdir directory_name: to delete an empty directory
rm -r dir_name: to delete the non
To create a fruits.txt file and to view the content.
- touch is used to create the file. Example "touch filename.txt"
Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
we can use echo, vi or vim to enter the content in fruits.txt file
To Show only top three fruits from the file we can use "head -n filename"
To Show only bottom three fruits from the file we can use "tail -n filename"
To create another file Colors.txt and to view the content we use "touch colors.txt" and "cat colors.txt" to view contents
To find the difference between fruits.txt and Colors.txt file. we ill use "diff" command.
diff stands for difference. This command is used to display the differences in the files by comparing the files line by line
#linux #linuxadministration #devops #trainwithshubham #ubuntu #cloud #cloudengineering #administration #blogging #linuxguide #learning #development