When working on Linux, remembering useful commands will make the work more efficient. Here are some useful commands.
Show the path of the current directory
The current directory is the directory you are currently working on. You can use the pwd command to display the path of the current directory.
The path of the current directory is displayed as shown below.
Change current directory
Use the cd command to move the current directory.
The directory name can be either a relative path relative to the current directory or an absolute path that describes the complete path.
For example, if you are working in the current directory "/home/kimoto" and want to move to the directory "labo" directly under this, do as follows.
You can also move by specifying the absolute path.
Abbreviated notation of home directory
Here are some techniques for the cd command. You can use the directory name "~" to move to the user's home directory.
If the user is kimoto, it has the same meaning as the following specification.
Specify easily using wildcards
Actually, when moving with cd, if you use wildcards, you do not need to specify all the names of the directory name.
* is a wildcard, and if you specify "la*", you can move to the directory "labo" if it exists. Typing or copying and pasting all names is a useful technique when you're having trouble.
Display the list of files contained in the directory
Use the ls command to display the list of files contained in the directory (including the directory).
A list of files will be displayed as shown below.
README lib script
Use the l option to include information such as file permissions and file size.
You can see the detailed information of the file as follows.
-rw-rw-r-- 1 kimoto kimoto 588 June 16 13:19 README drwxrwxr-x 3 kimoto kimoto 4096 June 16 16:39 lib drwxrwxr-x 2 kimoto kimoto 4096 June 25 19:21 script
The permission setting is on the far left. Permissions are the permissions on a file. I would like to introduce the idea later in this series.
See hidden files
The ls command does not display hidden files starting with. (Dot) by default. Use the a option to display hidden files.
By doing this, hidden files can also be displayed.
In Linux, you can specify multiple options. For example, you can specify both advanced and hidden file display options.
Narrow down the files to be displayed with wildcards
You can narrow down the files to be displayed by using wildcards.
If you specify as above, you can display only the files starting with 2012.