Basic Linux commands
Linux Decoded: Unlocking the Secrets of Essential Command Line Tools
What Is a Linux Command?
A Linux command is a program or utility that runs on the CLI – a console that interacts with the system via texts and processes. It’s similar to the Command Prompt application in Windows.
Here’s what a Linux command’s general syntax looks like:
CommandName [option(s)] [parameter(s)]
A command may contain an option or a parameter. In some cases, it can still run without them. These are the three most common parts of a command:
CommandName is the rule that you want to perform.
Option or flag modifies a command’s operation. To invoke it, use hyphens (–) or double hyphens (—).
Parameter or argument specifies any necessary information for the command.
Keep in mind that all Linux commands are case-sensitive.
Listing commands
ls option_flag arguments
--> List the sub-directories and files available in the present directory.
ls -l
--> List the files and directories in a long list format with extra informationls -a
--> List all including hidden files and directories.ls *.sh
--> List all the files having .sh extensionls -i
--> List the files and directories with index numbers Inodes.ls -d */
--> list only directories.(we can also specify a pattern)
Directory commands
pwd
--> Print work directory. Gives the present working directory.cd path_to_directory
--> Change the directory to the provided pathcd ~
or justcd
--> Change the directory to the home directorycd -
--> Go to the last working directory.cd ..
--> Change the directory to one step back.Mkdir Examples:
mkdir FolderSK
--> Make a new folder 'new folder'.mkdir .HideMe
--> Make a hidden directory (also . before a file to make it hidden).mkdir A B C D
--> Make multiple directories at the same time.mkdir /home/user/Mydirectory
--> Make a new folder in a specific location.mkdir -p A/B/C/D
--> Make a nested directory.
Commonly Used Linux commands:
sudo (command) #lets you perform tasks that require administrative or root permissions.
pwd [option] #To find path of your current working directory
cat filename.txt. #It lists, combines, and writes file content to the standard output.
cp filename1.txt filename2.txt #to copy files or directories and their content.
touch /home/username.html #to create an empty file or generate and modify a timestamp in the Linux command line.
locate -i school*note #find a file in the database system.
grep blue notepad.txt #to find a word by searching through all the texts in a specific file.
df -h #to report the system’s disk space usage, shown in percentage and kilobyte (KB).
du /home/user/Documents #to check how much space a file or a directory takes up
head note.txt # to view the first ten lines of a text
tail -n colors.txt #to displays the last ten lines of a file.
diff note.txt note_update.txt #the diff command compares two contents of a file line by line.
tar -cvf newarchive.tar /home/user/Documents #archives multiple files into a TAR file – a common Linux format similar to ZIP, with optional compression.
chmod 777 note.txt #to modifies a file or directory’s read, write, and execute permissions.
kill SIGKILL 63773 # to terminate an unresponsive program manually.
ping google.com #for checking whether a network or a server is reachable.
wget https://wordpress.org/latest.zip # lets you download files from the internet
Thanks for reading my article. Have a nice day.
For updates follow me on LinkedIn: Swapnil Khairnar
Hashtags:
#90daysofdevops #devops #cloud #aws #awscloud #awscommunity #docker #linux #kubernetes #k8s #ansible #grafana #terraform #github #opensource #90daysofdevops #challenge #learningprogress #freelancer #linkedin #trainwithshubham #devopscommunity #cloudproviders #bash #bashshellscripting #awkward #shellscripting