Table of contents
- Checking Your Present Working Directory:
- Listing All Files and Directories Including Hidden Files:
- Creating a Nested Directory A/B/C/D/E:
- Navigating to a Different Directory:
- Copying Files and Directories:
- Moving and Renaming Files and Directories:
- Deleting Files and Directories:
- here are some other useful Linux commands:
- Conclusion:
Certainly! In this article, I will cover some basic Linux commands along with demonstrations to help you navigate your system, list files and directories, create nested directories, and copy files and directories.
Checking Your Present Working Directory:
To check your present working directory, use the
pwd
command as shown below:
$ pwd
/home/user/Documents
In this example, the pwd
command shows that the current working directory is /home/user/Documents
.
Listing All Files and Directories Including Hidden Files:
To list all files and directories, including hidden ones, use the
ls
command with the-a
option as shown below:
$ ls -a
. .. file1 file2 .hiddenfile directory1 directory2
In this example, the ls -a
command shows all files and directories in the current directory, including hidden ones (.hiddenfile
).
Creating a Nested Directory A/B/C/D/E:
To create a nested directory A/B/C/D/E, use the
mkdir
command with the-p
option as shown below:
$ mkdir -p A/B/C/D/E
This command will create the nested directory A/B/C/D/E
even if any of the intermediate directories do not exist.
Navigating to a Different Directory:
To navigate to a different directory, use the
cd
command followed by the directory path as shown below:
$ cd /home/user/Documents
This command will navigate to the /home/user/Documents
directory.
Copying Files and Directories:
To copy files or directories, use the
cp
command followed by the source and destination paths as shown below:
$ cp file.txt /home/user/Documents/
This command will copy the file.txt
file from the current directory to the /home/user/Documents
directory.
If you want to copy a directory and its contents, use the -r
option with the cp
command as shown below:
$ cp -r directory1 /home/user/Documents/
Moving and Renaming Files and Directories:
To move files or directories, use the
mv
command followed by the source and destination paths as shown below:
$ mv file.txt /home/user/Documents/
This command will move the file.txt
file from the current directory to the /home/user/Documents
directory.
To rename a file or directory, use the mv
command with the new name as shown below:
$ mv file.txt newfile.txt
This command will rename the file.txt
file to newfile.txt
.
Deleting Files and Directories:
To delete a file, use the
rm
command followed by the file name as shown below:
$ rm file.txt
This command will delete the directory1
directory and all of its contents.
here are some other useful Linux commands:
grep: search for a specific pattern in a file or set of files
chmod: change the permissions of a file or directory
chown: change the ownership of a file or directory
ps: display information about running processes
top: display real-time information about system resources and processes
tar: create or extract compressed archive files
ssh: remotely connect to another machine using Secure Shell protocol
scp: securely copy files between machines using SSH
wget: download files from the internet
curl: transfer data from or to a server using various protocols
These are just a few of the many commands available in Linux. Each command has its own set of options and parameters, so it's important to read the manual pages (man <command>
) for more information on how to use them.
Conclusion:
In this article, I have covered some basic Linux commands to help you navigate your system, list files and directories, create nested directories, copy files and directories, move and rename files and directories, and delete files and directories. By mastering these commands, you can become more efficient and productive when working with Linux systems. There are many other commands available in Linux, but these are some of the most commonly used ones. With practice and experience, you can become an expert in Linux system administration.