mkdir
Following the previous day commands on working with directories , The next command will be about how you can create a directory or a folder for yourself in the terminal. i.e mkdir
eg: mkdir newdirectory
There is a switch available for this command that allows you to create multiple directories within another directory by using mkdir -p
eg:mkdir -p mydir2/mysubdir2
rmdir
This command allows you to delete a directory when it is empty.otherwise it will show that the directory cannot be deleted.
eg:rmdir newdirectory
This also has the same switch that allows you to delete the parent directories recursively.
eg:rmdir -p mydir2/mysubdir2
File Management Commands
These commands allow you to create, modify , delete files.All the files are case sensitive and therefore treated as different files.
file
The file command shows the datatype of a file.Linux does not use extensions to determine the type of a file.The file command uses a magic file(literally it's name) that contains patterns to recognise file types.file is located in /usr/share/file/magic.
eg:file file54.pdf , file /etc/passwd
touch
The touch command allows you to create an empty file.
eg: touch file86.txt
Like other commands , This command also has multiple switches available like:
- touch -t = allows you to set the time on when the file was created. eg: touch -t 2412311159 demo.txt
rm
This command removes a file forever since it will not be sent to trash or recycle bin.
eg:rm file86.txt
The switches available for this commands are:
rm -i = using this switch prevents accidental deletion of a file by asking for confirmation before deleting the file.
rm -rf = This switch recursively deletes the file forcefully. It can even delete everything if not used in the proper environment. So be careful when you use it.
Wrapping up
This will be the commands for today. Try experimenting on them to your preferences and also refer to man pages if you want to learn a lot more.
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.