Getting Started With Linux
An overview of basic linux commands
Linux Basic Commands
Linux is a powerful and versatile operating system with a command-line interface (CLI) that provides access to a wide range of functionalities. Here are some essential basic commands to get you started:
1. ls (List Files)
- Purpose: Displays a list of files and directories in the current directory.
- Options:
-l: Lists files in a long format, showing details like permissions, owner, size, and modification time.-a: Lists all files, including hidden files (starting with a dot “.”).-h: Displays file sizes in a human-readable format (e.g., 1.5K, 2.3M, 1.2G).
2. cd (Change Directory)
- Purpose: Navigates to a different directory in the file system.
- Usage:
cd /: Changes to the root directory.cd ..: Moves to the parent directory.cd Documents: Changes to the “Documents” directory.
3. pwd (Print Working Directory)
- Purpose: Displays the current directory path.
4. mkdir (Make Directory)
- Purpose: Creates a new directory.
- Usage:
mkdir new_directory
5. rmdir (Remove Directory)
- Purpose: Deletes an empty directory.
- Usage:
rmdir empty_directory
6. touch (Create or Update File)
- Purpose: Creates an empty file or updates the timestamp of an existing file.
- Usage:
touch new_file.txt
7. cp (Copy Files)
- Purpose: Copies files or directories.
- Usage:
cp file1.txt file2.txt: Copies “file1.txt” to “file2.txt”.cp -r directory1 directory2: Recursively copies the “directory1” to “directory2”.
8. mv (Move or Rename Files)
- Purpose: Moves or renames files or directories.
- Usage:
mv file1.txt new_location/: Moves “file1.txt” to the “new_location” directory.mv file1.txt new_filename.txt: Renames “file1.txt” to “new_filename.txt”.
9. rm (Remove Files)
- Purpose: Deletes files or directories.
- Usage:
rm file1.txt: Deletes “file1.txt”.rm -r directory1: Recursively deletes the “directory1” (use with caution).
10. cat (Concatenate and Print Files)
- Purpose: Displays the contents of files to the terminal.
- Usage:
cat file1.txt
11. grep (Global Regular Expression Print)
- Purpose: Searches for patterns within files.
- Usage:
grep "search_term" file1.txt
12. man (Manual)
- Purpose: Displays the manual pages for a command.
- Usage:
man ls
13. sudo (Super User Do)
- Purpose: Executes commands with root privileges.
- Usage:
sudo apt update
14. apt (Advanced Packaging Tool)
- Purpose: Used for installing, updating, and removing software packages.
- Usage:
sudo apt update: Updates the package lists.sudo apt install package_name: Installs the specified package.sudo apt upgrade: Upgrades existing packages.
This is just a starting point. Linux offers a vast array of commands and utilities. By learning and practicing these basic commands, you’ll gain a solid foundation for working with the Linux command line.
Note: Always use commands with caution, especially those that involve deleting files or directories. It’s recommended to practice in a safe environment or create backups before making significant changes.
I hope this article is helpful! Let me know if you’d like to explore more advanced Linux commands or specific topics.