Linux command [File operation]

Introduction

It will be a memo for learning.

*[]···Any <> ・ ・ ・ Absolutely

Text and binary files

text file

A text file is a file in which a character string is written.

Binary file

Binary files are image files, audio files, executable files, etc.

1.cat command

Display the contents of the file.

cat [option]<file name>

It is often used without options.

2. less command

A command that scrolls through the contents of a file. Used when viewing the contents of a long file.

less [option]<file name>

It is often used without options.

Scroll operation

command Contents
Space bar, f Scroll on one screen
b Scroll down one screen
j Scroll down one line
k Scroll up one line
q Exit less command

Search operation

command Contents
/ Search downwards
? Search upwards
n Move to the next search result
N Go to previous search results

3. touch command

Command to create an empty file

touch <New file name>

If the file name does not exist, create an empty file, and if it exists, update the time stamp.

4.rm command

Command to delete files and directories

rm [option]<File name to delete>

Note: If you execute the rm command, it will be deleted, not the trash can, so make sure that you can delete it before executing it.

Frequently used options

1.-r Delete the directory as well

rm -r dir

Note: Please note that files and directories in the directory will also be deleted at once. 2.-f Do not display a warning when deleting a file. Not recommended commands

rm -f file

3.-i Check before deleting files

rm -i file

5. mv command

Commands for moving and renaming files

#Concrete example
mkdir dir   //Create dir directory
touch file  //Create an empty file

##File name change
mv file file1

##Move files
mv file1 dir/   //Move file1 into the dir directory

option

-i Confirm before overwriting

mv -i file file1

6. cp command

Command to copy files and directories

cp [option]<Original>...<Copy to>

##Concrete example
#Copy file
cp file new file
#Copy files to no directory
cp file dir

Note: Be careful as it will overwrite the destination file if it already exists.

option

1.-i Confirm before overwriting

cp -i file new_file

2.-r Copy directory

cp -r dir new_dir

7. find command

Command to search files

find <Search start directory><Search conditions><Search action>

#Concrete example
find . -name README.md -print

Recommended Posts

Linux command [File operation]
Linux command # 4
Linux command # 5
Linux study session 2nd: File operation
[Linux] Frequently used Linux commands (file operation)
[Linux] File and directory operation commands
Linux command list
linux at command
[Linux] Search command
Linux [directory command]
Linux server command
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
My linux command
[Linux] File search
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
Linux operation for beginners Basic command summary
[Linux] Volume configuration command
Linux command cheat sheet
Linux command (sequential update)
Linux basic command memorandum
Adjust file permissions with the Linux command chmod
Hack Linux file descriptors
[Linux] Basic command summary
Linux command for self-collection
linux command error collection 1
Linux command line shortcut
Linux operation on Win10
linux sar command CPU usage
[Linux] tar.gz compression / decompression command
Device and Linux file system
What is Linux? [Command list]
Easy df command on Linux
Linux file and directory permissions
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
[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
How to output the output result of the Linux man command to a file
Linux
[Linux convenient command] Try inserting bat