Basic Linux Commands
Linux commands form the basis of interacting with the Linux operating system. Here are some main Linux commands:
- ls: List files and directories in the current location.
- Example:
ls -l
(detailed list),ls -a
(including hidden files)
2. cd: Change directory.
- Example:
cd /path/to/directory
(change to a specific directory),cd ..
(move to the parent directory)
3. pwd: Print the working directory, i.e., display the current directory.
4. mkdir: Create a new directory.
- Example:
mkdir new_directory
(create a directory named "new_directory")
5. rm: Remove files and directories.
- Example:
rm file.txt
(remove a file),rm -r directory
(remove a directory and its contents)
6. cp: Copy files and directories.
- Example:
cp file.txt new_location/file.txt
(copy a file to a new location),cp -r directory new_directory
(copy a directory and its contents)
7. mv: Move or rename files and directories.
- Example:
mv file.txt new_location/file.txt
(move a file to a new location),mv old_name.txt new_name.txt
(rename a file)
8. cat: Display the contents of a file.
- Example:
cat file.txt
(display the contents of "file.txt")
9. grep: Search for a specific pattern in files.
- Example:
grep "pattern" file.txt
(search for "pattern" in "file.txt")
10. chmod: Change file permissions.
- Example:
chmod +x script.sh
(add execute permission to "script.sh")
11. ssh: Securely connect to a remote server.
- Example:
ssh username@remote_host
(connect to "remote_host" with the given username)
12. sudo: Execute a command with administrative privileges.
These are just a few examples of the many commands available in Linux. You can explore further by referring to the documentation.