Let's learn the basic commands of Linux Part 1
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.
pwd
The path of the current directory is displayed as shown below.
/home/kimoto
Change current directory
Use the cd command to move the current directory.
cd DirectoryName
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.
cd labo
You can also move by specifying the absolute path.
cd /home/kimoto/labo
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.
cd ~
If the user is kimoto, it has the same meaning as the following specification.
cd /home/kimoto
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.
cd la*
* 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).
ls
A list of files will be displayed as shown below.
README lib script
See details
Use the l option to include information such as file permissions and file size.
ls -l
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.
ls -a
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.
ls -al
Narrow down the files to be displayed with wildcards
You can narrow down the files to be displayed by using wildcards.
ls 2012*
If you specify as above, you can display only the files starting with 2012.