Linux commands are the fundamental tools for interacting with the Linux operating system. Here are some of the most commonly used commands:
ls
Thels
command lists directory contents.
ls # Lists files and directories in the current directory
ls -l # Lists in long format, showing permissions, ownership, and size
ls -a # Includes hidden files (those starting with .)
cd
Thecd
command changes the current directory.
cd /home/user # Changes to the specified directory
cd .. # Moves up one directory level
cd ~ # Changes to the home directory
pwd
Thepwd
command prints the current working directory.
pwd # Displays the full path of the current directory
cp
Thecp
command copies files or directories.
cp file1.txt file2.txt # Copies file1.txt to file2.txt
cp -r dir1/ dir2/ # Recursively copies directory dir1 to dir2
mv
Themv
command moves or renames files and directories.
mv oldname.txt newname.txt # Renames oldname.txt to newname.txt
mv file.txt /path/to/directory/ # Moves file.txt to the specified directory
rm
Therm
command removes files or directories.
rm file.txt # Removes the specified file
rm -r directory/ # Recursively removes the directory and its contents
rm -f file.txt # Forces removal without prompting
mkdir
Themkdir
command creates a new directory.
mkdir newdir # Creates a new directory named newdir
rmdir
Thermdir
command removes empty directories.
rmdir emptydir # Removes the specified empty directory
touch
Thetouch
command creates an empty file or updates the timestamp of an existing file.
touch newfile.txt # Creates a new empty file named newfile.txt
cat
Thecat
command concatenates and displays file content.
cat file.txt # Displays the content of file.txt
grep
Thegrep
command searches for patterns within files.
grep "search_term" file.txt # Searches for search_term in file.txt
grep -r "search_term" /directory/ # Recursively searches in the specified directory
chmod
Thechmod
command changes file permissions.
chmod 755 file.sh # Sets read, write, and execute permissions for owner, and read and execute for group and others
chown
Thechown
command changes file ownership.
chown user:group file.txt # Changes ownership of file.txt to user and group
ps
Theps
command displays currently running processes.
ps # Lists processes running in the current shell
ps aux # Lists all running processes with detailed information
kill
Thekill
command sends a signal to terminate processes.
kill PID # Sends the default SIGTERM signal to the process with the specified PID
kill-9 PID # Forces termination with SIGKILL
I think you are here to get to know me.
🌐 Connect with me across platforms.
🤝 Hit me up on these links, and let's turn ideas into action!