I was keenly aware of the lack of knowledge of Linux when building AWS, so I will review the basic commands again.
Basic commands used when you want to manipulate directories.
A command to move directories.
#Move to root dictator
cd /
Display the current directory (where you are).
pwd
/Users/hukushima
A command to list in a directory.
ls
Applications Public
Creative Cloud Files VirtualBox VMs
Desktop bash
You can specify multiple files at once.
ls *.html
index.html home.html
-a Show hidden files as well.
ls -a
.DS_Store media-3-211-600x600.jpg
.localized index.html
-l Display detailed information about the file.
ls -l
drwxr-xr-x 10 hukushima staff 320 3 29 19:59 javascript_practice
-rw-r--r--@ 1 hukushima staff 44368 4 20 01:03 media-3-211-600x600.jpg
-rw-r--r--@ 1 hukushima staff 296 3 28 21:09 index.htm
A command to create a directory.
mkdir work
-p Create a deep directory.
mkdir -p work/test/2020
Commands used when you want to work with files.
A command to check the contents of a file.
cat test.txt
test
test
-n It also displays the line number.
cat -n test.txt
1 test
2 test
A command to create a file.
touch index.html
A command to delete a file.
rm index.html
-r Delete the directory as well. All the contents are completely deleted.
rm -r dir
-f Do not display a warning when deleting. Often used in combination with -r.
rm -r dir
rm -rf dir
Commands for moving and renaming files.
#File name change
#Before change of mv After change
mv index.html home.html
#Move files
#File name Move destination directory
mv home.html dir
Copy files and directories.
#Copy file
cp index.html new_index.html
#Copy files to directory
cp index.html dir
-r Copy the directory.
cp -r dir new_dir
Command to paste a link. It's a shortcut in Windows.
Give multiple names to the actual state of one file. It does not disappear even if it is deleted. But an image that I don't use much.
ln file_a file_b
With Windows shortcuts. It is connected to the linked file.
ln -s file_a file_c
A command to find a file or directory.
#find Search start directory Search condition Search action
find . -name index.html -print
You can also use wildcards.
For the time being, I think I often use commands around here. Although it is the basic of the basics, it is called Fukane Koji, the source of drinking water. Since the basics are important for everything, I would like to thoroughly operate commands while waiting at home.
See you soon.
Recommended Posts