In this post, we will learn some commonly File commands on Linux operating system. We can use these commands in the bash terminal or in bash scripts.
mkdir command is used to create a directory in Linux. To create a directory called ubuntu, type the following command in the terminal window:
$ mkdir ubuntu
The new directory would be created under the present working directory. To navigate we can use the cd command.
rmdir command is used for removing the directory.
:~$ rmdir ubuntu
Common errors while using this command is: providing a non-existent directory name or trying to remove a directory that is not empty.
There are so many ways to create a file in Linux. Using touch command, cat command, etc.
touch command creates a new file if it doesn’t exist in the directory. If the file already exists then it will change the modification timestamp of the file. To learn more about touch command use
$ man touch
To create a new file with touch, use the following command:
$ touch sample.txt
cp command is used in Linux to copy the file. This command copies the file to the new location.
Format of the command is
cp file <new location>
$ cp toBecopied.txt ubuntu/
mv command can be used to move the file to a new location.
We can use the rm command to remove a file.
$ rm -rf sample.txt
To know the flags and to learn more about the command, use the below command:
$ man rm
Linux Basic Commands Tutorial page:
More Information on Ubuntu Linux: