Linux command <Basic 2>

Linux command basics 2.

find command

Find the file

[wataru@localhost testgo]$ find . -name work.08.txt -print
#find <Search start position> <Search conditions> <action>Format
#-print is an action that prints the pathname (if the action is omitted)-It is considered that print is specified)
./work.08.txt
[wataru@localhost testgo]$ find . -name 'work.0*' -print
#-If you use wildcards in name,''(Single quote)Surround with
#""(Double quotation)But yes
./work.02.txt
./work.05.txt
./work.06.txt
./work.07.txt
./work.08.txt
./work.09.txt
[wataru@localhost testgo]$ find . -name "work.0*"
#""(Double quotation)But it is searched without problems
#-If you omit print, it will be automatically-Considered to have specified print
./work.02.txt
./work.05.txt
./work.06.txt
./work.07.txt
./work.08.txt
./2020dir/work.09.txt
[wataru@localhost testgo]$ find . -type d
#-Use type d to search directories
.
./2020dir
[wataru@localhost testgo]$ find . -type f
#-Use type f to search for files
./work.02.txt
./work.05.txt
./work.06.txt
./work.07.txt
./work.08.txt
./testtest.txt
./2020dir/work.09.txt
[wataru@localhost testgo]$ ls
2020dir       work.02.txt  work.04.xls  work.06.txt  work.07.xls  work.09.xls
testtest.txt  work.02.xls  work.05.txt  work.06.xls  work.08.txt  work.10.xls
work.01.xls   work.03.xls  work.05.xls  work.07.txt  work.08.xls

wataru@localhost testgo]$ find . -type f -name '*xls'
#-type f and-name can be used together
./work.01.xls
./work.02.xls
./work.03.xls
./work.04.xls
./work.05.xls
./work.06.xls
./work.07.xls
./work.08.xls
./work.09.xls
./work.10.xls

vi command

Text editor

Basic commands

command Contents
:q Quit vi
:w Save the file by overwriting
:w Save it after naming it
:q! Exit vi without saving the file

Move command

command Contents
gg Move to the first line
G Move to the last line
G Move to the line
[wataru@localhost testgo]$ vi work.05.txt 
ABCDEFG
HIJKLMN
OPQRSTUWwaq
abcdef

123456
345678
7890                                                              
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                                                                                             
~                                                                           
~                                                                               
-- INSERT --  
#Enter i or a to enter insert mode
#Enter the Esc key to exit insert mode

Cut, copy, paste

Delete command

command Contents
d$ Delete to the end of the line
dgg Delete up to the first line
dG Delete to the last line
ABCDEFG
HIJKLMN
OPQRSTUWwaq
abcdef

123456
345678
#d$And deleted until the end of the line(7890 Deleted)
~                                                                               
~                                                                               
~                                                                               
"work.05.txt" 9L, 56C     
ABCDEFG
HIJKLMN
OPQRSTUWwaq
abcdef

1234562345623456
#d$The character string deleted in can be pasted using p.
345678

Search

You can search by entering / (slash) in normal mode.

HIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMN
HIJKLMN
OPQOPQOPQ

OPQOPQOPQ

HIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMN
HIJKLMN

HIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMN
HIJKLMN


HIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMNHIJKLMN
# /Enter the character you want to search after
/HI     

chmod command

Change file mode

wataru@localhost testgo]$ ls -l 
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
-rw-rw-r--. 1 wataru wataru  0 Jul  5 04:26 testtest.txt

[wataru@localhost testgo]$ chmod u+x testtest.txt
#chmod [ugoa][+-=][rwx] <file name>You can set permissions with
#This time, testtest.Added execute permission to the owner of the txt file
[wataru@localhost testgo]$ ls -l
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
-rwxrw-r--. 1 wataru wataru  0 Jul  5 04:26 testtest.txt

chmod user specification

symbol meaning
u Owner
g group
o Other users
a ugo all
[wataru@localhost testgo]$ chmod u-rx testtest.txt
#testtest.Prohibited read and write permissions on txt file owners
[wataru@localhost testgo]$ ls -l
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
--w-rw-r--. 1 wataru wataru  0 Jul  5 04:26 testtest.txt
[wataru@localhost testgo]$ chmod a+rwx testtest.txt
#Set read, write, and execute permissions for all users
[wataru@localhost testgo]$ ls -l
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
-rwxrwxrwx. 1 wataru wataru  0 Jul  5 04:26 testtest.txt
-rw-rw-r--. 1 wataru wataru  0 Jul 11 01:55 work.txt
[wataru@localhost testgo]$ chmod 444 testtest.txt
#Permission can be set even with numerical values
#This time, read only setting
[wataru@localhost testgo]$ ls -l
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
-r--r--r--. 1 wataru wataru  0 Jul  5 04:26 testtest.txt
-rw-rw-r--. 1 wataru wataru  0 Jul 11 01:55 work.txt

Permission numbers in numeric mode

Numerical value meaning
4 reading
2 writing
1 Run
[wataru@localhost testgo]$ chmod 660 testtest.txt
#Set read and write permissions for owners and groups
[wataru@localhost testgo]$ ls -l
total 0
drwxrwxr-x. 2 wataru wataru 25 Jul  7 16:25 2020dir
-rw-rw----. 1 wataru wataru  0 Jul  5 04:26 testtest.txt
-rw-rw-r--. 1 wataru wataru  0 Jul 11 01:55 work.txt

Recommended Posts

Linux command <Basic 2>
[Basic] linux command
Linux command <Basic 1>
Linux basic command memorandum
[Linux] Basic command summary
Linux command # 4
Linux command # 5
Linux command list
linux at command
[Linux] Search command
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
Linux [shell command]
Basic LINUX commands
[Linux] Command / Knowledge
My linux command
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux command (basic in basic) personal memo
Linux (command memory)
Linux operation for beginners Basic command summary
[Linux] Volume configuration command
Linux command cheat sheet
Linux command (sequential update)
Linux command [File operation]
Basic knowledge about Linux
Basic Python command memo
Linux command for self-collection
linux command error collection 1
Linux command line shortcut
linux sar command CPU usage
CLI and Linux basic terms
[Linux] tar.gz compression / decompression command
What is Linux? [Command list]
[Copy and paste OK] Basic Linux command collection [18 selections]
virtualenv Basic command usage memo
Easy df command on Linux
Linux
Linux tar xz command memo
Linux Command Dictionary (for myself)
linux: create original Terminal command
[Note] Useful linux command collection
Linux command memorandum [for beginners]
Linux PC spec check command
[Linux] User / group command summary
[Infrastructure] Linux command, shell script collection
Basic knowledge of Linux and basic commands
[Linux convenient command] Try inserting exa
Command to create Linux Live USB
[Linux] OS recovery with restore command
Completion of docker command on Linux
[Linux convenient command] Try inserting csview
Permission and ownership change command [Linux]
LINUX command [wc edition] Usage example
Linux command [ldconfig] LPIC learning memo
[linux] kill command to kill the process