Creation Commands
Creation Commands
In your learning journey you have very likely heard the acronym CRUD. Which stands for:
- Create
- Read
- Update
- Delete
This is the collection of actions you can perform on any given record, object, or in the case of Linux: files/directories.
In the following sections we will be learning about, and practicing, some commands that can be used to perform CRUD actions on files and directories from our Bash shell.
Create Directory
You can create a new directory with the mkdir
command. Let’s use it to create a new directory named temp
in our home directory. With your current working directory as your home directory enter:
mkdir temp
When mkdir
runs successfully there is no standard output (STDOUT
) displayed to the user. To see the new directory you can run the ls
command to see the contents that were created in the current working directory.
You can use absolute or relative paths with the mkdir
command.
Create File
You can create a new empty file with the touch
command. In our home directory let’s create a new file called temp.file
.
touch temp.file
Again, a successful touch
command will provide no message to standard output (STDOUT
). To see the new temp.file
you will need to run the ls
command as shown in the picture.
Creating Hidden Files/Directories
A hidden file or directory is denoted by the name starting with a period (.
). We can create hidden files and directories using the exact command above, but adding the period (.
) to the file name.
Hidden Directory
From your home directory create a new hidden-directory:
mkdir .hidden-directory
To see this new hidden directory we will need to run the ls
command with the the -a
option so all files are displayed.
You may have to look for it, but you should find the new .hidden-directory
that resulted from the execution of the mkdir
command.
Hidden File
Let’s change into the new .hidden-directory
.
Now create a new hidden file named .hidden.file
.
touch .hidden.file
To see the hidden file you will again need to run:
ls -a