1.2 Mastering the Basics: Unveiling the Power of Essential Linux Commands Part-1

1.2 Mastering the Basics: Unveiling the Power of Essential Linux Commands Part-1

Here's a basic introduction to some common Linux commands:

  1. pwd: Stands for "Print Working Directory." It shows you the current directory you are in.

  2. 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).

  3. 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.

  4. mkdir: Stands for "Make Directory." It is used to create new directories.

    • mkdir <directory_name>: Creates a new directory with the given name.
  5. rmdir: Stands for "Remove Directory." It is used to remove empty directories.

    • rmdir <directory_name>: Removes the specified empty directory.
  6. 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).

  7. 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.

  8. 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.

  9. cat: Stands for "Concatenate." It is used to display the contents of a file.

    • cat <file_name>: Displays the content of the specified file.
  10. echo: Prints a message or value to the terminal.

    • echo <message>: Displays the message on the terminal.
  11. 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.
CommandDescription
lsLists all files and directories in the present working directory
ls -RLists files in sub-directories as well
ls -aLists hidden files as well
ls -alLists files and directories with detailed information like permissions,size, owner, etc.
cd or cd ~Navigate to HOME directory
cd ..Move one level up
cdTo change to a particular directory
cd /Move to the root directory
cat > filenameCreates a new file
cat filenameDisplays the file content
cat file1 file2 > file3Joins 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_nameRenames the file to a new filename
sudoAllows regular users to run programs with the security privileges of the superuser or root
rm filenameDeletes a file
manGives help information on a command
historyGives a list of all past commands typed in the current terminal session
clearClears the terminal
mkdir directorynameCreates a new directory in the present working directory or a at the specified path
rmdirDeletes a directory
mvRenames a directory
pr -xDivides the file into x columns
pr -hAssigns a header to the file
pr -nDenotes the file with Line Numbers
lp -nc , lpr cPrints “c” copies of the File
lp-d lp-PSpecifies name of the printer
apt-getCommand 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 < FilenameCommand 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!

Introduction to Devops

💡
Stay updated for more such blogs. Happy Learning

Did you find this article valuable?

Support Vijay Kumar Singh by becoming a sponsor. Any amount is appreciated!