Recently I started studying for LPIC Level 1. This time, I wrote on the theme that I wish I knew this half a year ago (4 months after joining the company).
Linux is often mentioned side by side with Windows and macOS, so at that time I thought it was one of the operating systems. Speaking of a strict definition, Linux is a kernel (the core part of the OS) in a narrow sense, and it is a part that plays a particularly important function for the OS such as memory management and input / output management. On the other hand, it may also refer to Linux as an OS in a broad sense. When you speak the word "Linux", you need to think about what you are referring to and what you are using. I have a feeling, but when the word "Linux" comes out, I feel that it is often used in the (broad sense) sense of the OS.
A Linux distribution is an operating system that has been made to behave like UNIX by adding libraries to Linux (kernel). Talking side by side with Windows and macOS refers to this Linux distribution. Typical examples are ** Red Hat-based distributions (CentOS, etc.) ** developed by Red Hat, and ** Debian-based distributions (ubuntu, etc.) ** developed by the Debian Project. Hereinafter, Linux distributions are collectively referred to as Linux OS.
The operation of LinuxOS is basically CUI (Command Line Interface), and it is a little difficult for those who are accustomed to operation by GUI (Graphical User Interface) using a mouse or the like. For example, use the ** ls command ** to see a list of files in a directory. To work well with the Linux OS, you need to remember commands like ** ls ** and options to condition their behavior, but sometimes it's hard to remember. In such cases, the ** man ** command and ** --help ** option are useful.
$ man ls
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of
-cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
(Omitted)
$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--block-size=SIZE with -l, scale sizes by SIZE when printing them;
e.g., '--block-size=M'; see SIZE format below
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'always' (default
if omitted), 'auto', or 'never'; more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
(Omitted)
Displays a description of the command specified by the ** man ** command or **-help ** option and the options of that command. Command names and options are often abbreviations for basically behavioral words. Rather than just remembering commands and options as strings, knowing their meaning makes them much easier to remember.
For example, the command to display the current working directory is the ** pwd ** command. If you just remember this as ** "pwd" ** or ** abbreviation for "print working directory" **, I think the latter is easy to remember.
The origin of the command is summarized on the here page for easy viewing.
The ** -l ** option of the ** ls ** command is a very useful option that shows the permissions and owners of the files in the directory.
~/testdir# ls
test1.txt test2.txt
~/testdir# ls -l
total 0
-rw-r--r-- 1 root root 0 Jan 14 22:10 test1.txt
-rw-r--r-- 1 root root 0 Jan 14 22:10 test2.txt
By adding aliases to frequently used commands like this, you can operate them more easily. To give an alias, use the ** alias ** command
~/testdir# alias ll='ls -l'
~/testdir# ll
total 0
-rw-r--r-- 1 root root 0 Jan 14 22:10 test1.txt
-rw-r--r-- 1 root root 0 Jan 14 22:10 test2.txt
The ** locate ** command is useful for finding files
[root@6f07fde89980 testdir]# ls
testFile1.txt testFile2.txt
[root@6f07fde89980 testdir]# locate testFile
/testdir/testFile1.txt
/testdir/testFile2.txt
There is a ** find ** command that shows similar behavior, but the ** locate ** command can search faster. This is because the ** find ** command searches for files in real time, while the ** locate ** command searches the DB where the file path is stored. Therefore, the ** locate ** command may not be able to search the file immediately after creation (file whose file path is not registered in the DB). To update the DB of the file path, use the ** updatedb ** command.
The locate command may not be installed pre-installed on the Linux OS It can be installed with the ** apt-get ** command on ubuntu and the ** yum ** command on centos.
# apt-get install mlocate
# yum install mlocate
Recommended Posts