1.2 Mastering the Basics: Unveiling the Power of Essential Linux Commands Part-1
Here's a basic introduction to some common Linux commands:
pwd
: Stands for "Print Working Directory." It shows you the current directory you are in.ls
: Lists files and directories in the current directory.ls -a
: Lists all files and directories, including hidden files.ls -l
: Displays detailed information about files and directories, such as permissions, owner, size, and modification date.ls -h
: Shows file sizes in a human-readable format (e.g., KB, MB, GB).
cd
: Stands for "Change Directory." It allows you to navigate between directories.cd <directory_name>
: Moves you to the specified directory.cd ..
: Moves you up one level to the parent directory.cd ~
: Takes you to your home directory.
mkdir
: Stands for "Make Directory." It is used to create new directories.mkdir <directory_name>
: Creates a new directory with the given name.
rmdir
: Stands for "Remove Directory." It is used to remove empty directories.rmdir <directory_name>
: Removes the specified empty directory.
rm
: Stands for "Remove." It is used to delete files and directories.rm <file_name>
: Removes the specified file.rm -r <directory_name>
: Removes a directory and its contents recursively (use with caution).
cp
: Stands for "Copy." It is used to copy files or directories.cp <source_file> <destination>
: Copies the source file to the destination.cp -r <source_directory> <destination>
: Copies a directory and its contents recursively.
mv
: Stands for "Move." It is used to move or rename files and directories.mv <source> <destination>
: Moves the source file or directory to the destination.mv <old_name> <new_name>
: Renames a file or directory.
cat
: Stands for "Concatenate." It is used to display the contents of a file.cat <file_name>
: Displays the content of the specified file.
echo
: Prints a message or value to the terminal.echo <message>
: Displays the message on the terminal.
man
: Stands for "Manual." It is used to display the manual page for a command.man <command>
: Shows the manual for the specified command. Press 'q' to exit the manual page.
Command | Description |
ls | Lists all files and directories in the present working directory |
ls -R | Lists files in sub-directories as well |
ls -a | Lists hidden files as well |
ls -al | Lists files and directories with detailed information like permissions,size, owner, etc. |
cd or cd ~ | Navigate to HOME directory |
cd .. | Move one level up |
cd | To change to a particular directory |
cd / | Move to the root directory |
cat > filename | Creates a new file |
cat filename | Displays the file content |
cat file1 file2 > file3 | Joins two files (file1, file2) and stores the output in a new file (file3) |
mv file "new file path" | Moves the files to the new location |
mv filename new_file_name | Renames the file to a new filename |
sudo | Allows regular users to run programs with the security privileges of the superuser or root |
rm filename | Deletes a file |
man | Gives help information on a command |
history | Gives a list of all past commands typed in the current terminal session |
clear | Clears the terminal |
mkdir directoryname | Creates a new directory in the present working directory or a at the specified path |
rmdir | Deletes a directory |
mv | Renames a directory |
pr -x | Divides the file into x columns |
pr -h | Assigns a header to the file |
pr -n | Denotes the file with Line Numbers |
lp -nc , lpr c | Prints “c” copies of the File |
lp-d lp-P | Specifies name of the printer |
apt-get | Command used to install and update packages |
mail -s 'subject' -c 'cc-address' -b 'bcc-address' 'to-address' | Command to send email |
mail -s "Subject" to-address < Filename | Command to send email with attachment |
These are just some of the basic Linux commands to get you started. As you become more familiar with the Linux environment, you'll find many more commands and options to explore!