Basic Linux/Unix Commands - Part 1
Let we start the basic Linux/unix commands - part 1
pwd Command
1. The command pwd displays the current working directory.
2. Simply use the pwd command to determine your current working directories.

Output
According to the output, the current home directory .

cd Command
1. cd command is used to navigate the directories.
2. For examples : Run the following command to go to the /var/log file path.

Output

3. cd . . is used to get back one step form the current directory.

4. cd is used to get back to the home directory.

ls Command
The ls command is used to list existing files or sub-folders in a directory.

Output

-a option is used to show the hidden files.

touch Command
1. The touch command is used to create zero size file .
syntax

2. Run the following command to create a sample.txt file.
and use ls command to list the created file.

cat command is used to view a specific file's contents .
syntax

mv Command
1. To transfer or rename files, by using the mv command.

2. When renaming a file, you may not be alerted that it may overwrite an existing file.
3. So, when issuing mv, always use the '-i' option as a precaution .

4. While moving the files, better to move more than 2 arguments like this,

5. If ~/Test already exists, mv will copy the files there.
6. If it doesn't exist, an error notice will appear, like this,

cp Command
1. The cp command is used to copies a file from one location to another location.
2. This command will be create duplicate file from original file.
Syntax

3. For examples, Copy the file sample.txt to the Public/docs/ directory

mkdir Command
1. Use the mkdir (make directory) command to create a new directory.

2. Let's make a new directory called project.

3. Use the -p argument to create a directory within another directory as shown below.

rmdir Command
1. The rmdir command is user to deletes a directory that is empty.
2. To delete or remove the tutorial directory, for example, use the command

3. If you try to delete a directory that isn't empty, you'll get an error message like the
one below.

rm Command
1. To delete a file, use the rm (remove) command.
Syntax

2. Example: Run the command to delete the file.txt file.

3. Using the -R option, you can recursively remove or delete a directory.
4. It's possible to delete an empty or non-empty directory also by using -R option.

5. Example: To delete the project directory, use the command

That’s It! In this topic, we have covered Basic Linux/unix Commands - Part 1
Comments
Post a Comment