

Must-Know Linux Terminal Commands with Practical Examples
source link: https://hackernoon.com/must-know-linux-terminal-commands-with-practical-examples
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Must-Know Linux Terminal Commands with Practical Examples


Must-Know Linux Terminal Commands with Practical Examples
5min
by @orioninsist
Muhammet Murat Kurkoglu
@orioninsist
Hi there! I'm Muhammet Murat Kurkoglu, the founder of...




Too Long; Didn't Read
The Linux terminal is a powerful tool that allows users to interact with their system through text-based commands. Having a grasp of basic terminal commands is crucial. In this guide, weโll explore some essential Linux terminal commands along with explanations and practical examples. The guide includes the tar, ls, mkdir, pwd, whoami, ping and date commands.
audio
element.@orioninsist
Muhammet Murat KurkogluHi there! I'm Muhammet Murat Kurkoglu, the founder of or...
Receive Stories from @orioninsist
Credibility
The Linux terminal is a powerful tool that allows users to interact with their system through text-based commands. Whether youโre a beginner or an experienced user, having a grasp of basic terminal commands is crucial. In this guide, weโll explore some essential Linux terminal commands along with explanations and practical examples.
Table of Contents
- tar - Archiving and Compression
- rm - Removing Files and Directories
- ls - Listing Files and Directories
- history - Command History
- whoami - Current User
- uname - System Information
- ping - Network Connectivity
- date - Current Date and Time
- cp - Copying Files and Directories
- mkdir - Creating Directories
- pwd - Present Working Directory
- cd - Changing Directories
- file - File Type Information
- head and tail - Viewing File Content
- echo - Printing to the Terminal
- more and cat - File Content Display
- mv - Moving and Renaming Files
- wc - Word Count and Line Count
- sort - Sorting Lines in Files
- grep - Searching for Text
- Conclusion
1. tar - Archiving and Compression
The tar command is used for archiving and compressing files and folders.
- Create a compressed archive of a file:
tar -zcvf archive.tar filename
- Create an archive of multiple files:
tar -zcvf archive2.tar filename1 filename2 filename3
- Create an archive of a folder:
tar -zcvf folder.tar folder/
2. rm - Removing Files and Directories
The rm command is used to remove files and directories.
- Remove a directory and its contents:
rm -r folder/
- Remove multiple files:
rm filename1 filename2 filename3
3. ls - Listing Files and Directories
The ls command lists the contents of a directory.
- List all files and directories in long format:
ls -al
4. history - Command History
The history command displays previously executed commands.
- Display command history:
history
- Clear command history:
history -c
5. whoami - Current User
The whoami command displays the current user.
- Display current user:
whoami
6. uname - System Information
The uname command provides system information.
- Display system and kernel information:
uname -a
- Display kernel release information:
uname -r
7. ping - Network Connectivity
The ping command checks network connectivity to a host.
- Ping a host four times:
ping -c4 orioninsist.org
8. date - Current Date and Time
The date command displays the current date and time.
- Display current date and time:
date
9. cp - Copying Files and Directories
The cp command is used to copy files and directories.
- Copy a file with a new name:
cp filename newfilename
- Copy a file to a specific directory:
cp filename /home/orion/
- Copy a directory and its contents recursively:
cp -r /home/orion/newfolder /tmp/newfolder
10. mkdir - Creating Directories
The mkdir command creates directories.
- Create a new directory:
mkdir newfolder
11. pwd - Present Working Directory
The pwd command displays the present working directory.
- Display current directory path:
pwd
12. cd - Changing Directories
The cd command is used to change directories.
- Change to the Desktop directory:
cd Desktop
- Move up one directory level:
cd ..
13. file - File Type Information
The file command provides information about file types.
- Determine file type:
file filename.txt
14. head and tail - Viewing File Content
The head and tail commands display the beginning and end of files.
- Display the first lines of a file:
head filename.txt
- Display the last lines of a file:
tail filename.txt
15. echo - Printing to the Terminal
The echo command prints text to the terminal.
- Append new content to a file:
echo "new content" >> filename.txt
16. more and cat - File Content Display
The more and cat commands display file content.
- Display file content with paging:
more filename.txt
- Concatenate and display multiple files:
cat filename.txt filename2.txt
17. mv - Moving and Renaming Files
The mv command moves or renames files and directories.
- Move a file to a new directory:
mv filename newfolder/
18. wc - Word Count and Line Count
The wc command counts words, lines, and characters in a file.
- Count words in a file:
wc -w filename.txt
- Count lines in a file:
wc -l filename.txt
19. sort - Sorting Lines in Files
The sort command sorts lines in files.
- Sort lines in a file:
sort filename.txt
- Sort lines based on the second field:
sort -k 2 filename.txt
20. grep - Searching for Text
The grep command searches for text in files.
- Search for a specific pattern:
grep "orion" filename.txt
- Search for a pattern and exclude matches:
grep -v "orion" filename.txt
Conclusion
These are just a few of the fundamental Linux terminal commands that can empower you to navigate and interact with your system efficiently. As you continue to explore the Linux terminal, youโll discover even more commands and functionalities that can help you streamline your workflow and manage your system effectively. So, dive in, experiment, and become a master of the Linux command line!
GitHub
โญ GitHub: https://github.com/orioninsist/linux-basic
Also published here.
. . . comments & more!
Recommend
-
10
Linux -- Examples of Everyday Linux Commands May 28, 2002 Linux :: Examples of Everyday Linux Commands Last updated: 6/16/2002; 10:20:39 AM ย T...
-
6
50 Most Frequently Used UNIX / Linux Commands (With Examples) by Ramesh Natarajan on November 8, 2010
-
8
-
11
We use cookies on our websites to deliver our online services. Details about how we use cookies and how you may disable them are set out in our Privacy Statement
-
7
November 3, 2021 / #Linux Learn the 50 Most-Used Linux & Terminal Commands
-
11
@techdobzBhargav KuvadiyaI'm a Freelancer , writer , electronics & Communication Engine
-
9
7 Must-Know Linux File Manipulation Commands By JT McGinty Published 23 hours ago With a command-focused OS like Linux, y...
-
8
Linux is fun! Huh. OK, so you donโt believe me. Mind me at the end of this article you will have to believe that Linux is actually a fun box.1. Command: sl (Steam Locomotive) You might be aware of command...
-
8
12 minute readTop Kubectl Commands You Must KnowApril 22, 2022If you are going through this article, you are presumably fam...
-
19
Linux Commands - Overview and ExamplesThe command line is one of the most powerful features of Linux. There exists a sea of Linux command line tools, allowing you to do almost everything you can think of doing on your Linux PC. However, t...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK