List of terminal commands you should definitely remember [with practice]
I have summarized the basic operations of the terminal that can perform various operations using UNIX commands that are especially used in Linax and macOS. There is also a function that allows you to practice intuitively while watching the preview, so please try it first. I’m sure you will remember it soon.
Let’s practice first
Create a new empty file [touch]
A command that creates an empty file. For example, type “touch index.html” to create an empty file called “index.html”.
Create a new empty file(style.css) | touch style.css |
---|
Create a new directory [mkdir]
This command creates a new directory (folder). You can learn it smoothly by remembering it as an abbreviation of make directory. For example, if you want to create a new directory “css”, type “mkdir css”.
Create a new directory (js directory) | mkdir js |
---|
Move directory [cd]
If you remember cd as an abbreviation of change directory, you can learn it smoothly. If you type the command cd only, you will move to the home directory, and if you enter a directory name with a half-width space after cd, that directory will be moved.
Move to a specific directory (css directory) | cd css |
---|---|
Move up one directory | cd .. |
Move to home directory | cd |
Rename file/Move file [mv]
It is easy to remember mv as an abbreviation for move. This is a command whose behavior changes depending on the input method, such as changing the file name or moving the file. It may be a little hard to remember at first. Let’s remember firmly. To move a file to a specific directory, separate it with a space after the file name and specify it with a relative path.
Move a specific file (move script.js to js directory) | mv script.js js |
---|---|
Change the file name (change index.html to index2.html) | mv index.html index2.html |
Delete file [rm]
A command that deletes a file. If you remember rm, which stands for remove, you can probably remember it in one shot. If you specify multiple files, you can delete multiple files at once. You can also delete the directory by adding the option -r. Be careful when doing this because the scary part of this command is that it will be deleted without going through the trash when deleting.
Delete file (delete style.css) | rm style.css |
---|---|
Delete multiple files (remove style.css and script.js) | rm style.css script.js |
Remove directory (remove css directory) | rm -r css |
Delete directory [rmdir]
Command to delete a directory (folder). If you remember rmdir as remove directory, you can remember it smoothly. Please note that the contents of the directory will also be deleted when you delete it, and like the rm command, it will be deleted without going through the trash can, so be careful when proceeding.
Delete directory (delete css directory) | rmdir css |
---|
Copy file [cp]
A command that copies a file or directory. Type -r and the option to copy the directory. It is easy to remember cp as an abbreviation for copy.
Copy the file (copy style.css to create style2.css) | cp style.css style2.css |
---|---|
Copy entire directory (copy css folder to css2 folder) | cp -r css css2 |
Display the list of current directory (current folder) [ls]
Command to display a list of files and directories in the current directory (folder) on the terminal. It is easy to remember ls as an abbreviation for list.
Display file list of current directory | ls |
---|---|
Detailed display of file list including hidden files | ls -all |
Display the path of the current directory (current folder) [pwd]
A command that displays the path of the current directory. It is convenient because you may need it when opening it with Finder. If you remember pwd as print working directory, you can remember it in one shot.
Display path of current directory (current folder) | pwd |
---|
Clear characters on the terminal (clear)
A command to erase characters on the terminal all at once. The command itself is not canceled, it is just a command to clean the display. I don’t like to mess up, so I clear it quite often.
Clear characters on terminal | clear |
---|
The comment will be displayed after approval by the site administrator. Please follow the manners and comment.