LINUX COMMANDS
LINUX COMMANDS
Linux
Commands |
Functions |
Displays
information about files in the current directory. |
|
Displays
the current working directory. |
|
Creates
a directory. |
|
To
navigate between different folders. |
|
Removes
empty directories from the directory lists. |
|
Copy
files from one directory to another. |
|
Rename
and Replace the files |
|
Delete
files |
|
Command
to get basic information about the OS |
|
Find
a file in the database. |
|
Create
empty files |
|
Create
shortcuts to other files |
|
Display
file contents on terminal |
|
Clear
terminal |
|
Display
the processes in terminal |
|
Access
manual for all Linux commands |
|
Search
for a specific string in an output |
|
Print
string or text to the terminal |
|
download
files from the internet. |
|
Displays
the current users name |
|
sort
the file content |
|
View
Calendar in terminal |
|
View
the exact location of any command typed after this command |
|
Check
the details of the file system |
|
Check
the lines, word count, and characters in a file using different options |
Linux commands syntax with examples
๐ 1. ls – List directory contents
- Syntax:
ls [options] [directory]
- Example:
ls #
Lists files in the current directory
ls -l # Long
listing format
ls -a #
Includes hidden files
ls /home/user #
Lists contents of a specific directory
๐ 2. cd – Change directory
- Syntax:
cd [directory]
- Example:
cd /home/user/Documents
# Go to Documents
cd ..
# Move up one directory
cd ~
# Go to home directory
๐ 3. touch – Create empty file
- Syntax:
touch [filename]
- Example:
touch file1.txt
# Create an empty file
๐ 4. cat – View or create files
- Syntax:
cat [options] [file(s)]
- Example:
cat file.txt
# Display content
cat > newfile.txt
# Create a file, input ends with CTRL+D
cat file1.txt file2.txt
# Concatenate files
๐ 5. cp – Copy files or directories
- Syntax:
cp [options] source destination
- Example:
bash
CopyEdit
cp file1.txt file2.txt
# Copy file
cp -r dir1/ dir2/
# Copy directory recursively
๐ 6. mv – Move or rename files
- Syntax:
mv source destination
- Example:
mv oldname.txt newname.txt
# Rename file
mv file.txt /home/user/
# Move file
๐ 7. rm – Remove files or directories
- Syntax:
rm [options] file
- Example:
rm file.txt
# Delete file
rm -r directory/
# Delete directory and contents
๐ 8. mkdir – Create directory
- Syntax:
mkdir [directory-name]
- Example:
mkdir newfolder
๐ 9. echo – Print text to terminal or file
- Syntax:
echo [text]
- Example:
echo "Hello World" # Print text
echo "Hello" > file.txt # Save text to file
๐ 10. pwd – Print working directory
- Syntax:
pwd
- Example:
pwd # Shows current
path
๐ฅ 11. man – Show manual/help
- Syntax:
man [command]
- Example:
man ls # Shows help
for 'ls' command
๐ฆ 12. sudo – Execute as superuser
- Syntax:
sudo [command]
- Example:
sudo apt update #
Run update with admin privileges
๐ 13. find – Search files
- Syntax:
find [path] -name [pattern]
- Example:
find /home -name "file.txt"
๐งต 14. grep – Search inside files
- Syntax:
grep [pattern] [file]
- Example:
bash
grep "hello" file.txt
Comments
Post a Comment