English
Miscellaneous Shell History (1)

Miscellaneous Shell History (1)

Your journey to learn Shell

File creation related

  • touch: Create file

  • mkdir: Create folder

  • chmod: Set file permissions

  • chown: Set file owner

  • mv: Move and rename files

Check file information

  • -rwxr-xr-x Part: Checking the file's permissions
  1. the first digit means File Type (-, d, l)
  2. read-write-execute permissions are expressed in 3-digit form for user, group, and others, The value of rwx can be changed to 7 and -xr can be changed to 4 because r has a value of 4, w has a value of 2, and x has a value of 1 in the form of a binary number.
chmod 744 Slack.lnk

This type of command can be used to set permissions. 3. Number of links (where 1 is written) 4. Information about the owner (blank) and ownership group (197609) 5. File size 6. Information about the last modified time 7. The file name

ssh-keygen

  • Used in many cases for Git authentication via Secure Shell public key

  • Included in Window and Linux packages

  • When generating a key, a key and .pub file is generated, which is used as a key-lock by providing the contents of the .pub file to the server

How to adjust the capacity of a file in the shell

mkfile -n 10k test.sh
fallocate -l 10k test.sh
truncate -s 10k test.sh

You can resize an existing file or create a new file with this command.

Change the file modification history

touch -t 2301011234 timefile.sh

Command to change the modification history of a file to show that it was last modified on 1/1/23/12:34 as an application of touch.

Hard Link & Symbolic Link

Symbolic Link (Soft Link)

A link that makes the original file available in a specific folder, such as a shortcut in Windows, and does not work if the original is deleted.

Hard Link

Unlike a symbolic link, the difference is that it copies the original and creates a copy; when the original is deleted, the symbolic link becomes unusable, but a hard link can still be used because it is the same file after all; links that are involved in the number of links.

Code

ln [대상 폴더] [만들 링크 파일명] # Hard Link
ln -s [대상 폴더] [만들 링크 파일명] # Symbolic Link

The erase command can be lifted with rm, just like erasing a file

Diff & Patch

diff a b > difference.patch

The diff command compares two files on a line-by-line basis, and the patch command allows you to modify a file based on the comparison made by diff.

patch -p{패치 경로의 depth} [원본] [patch 파일] # 패치 파일 적용
patch -p{패치 경로의 depth} -R [원본] [patch 파일] # 적용된 패치 파일을 되돌림

In the same form as above, you can apply and remove the contents determined through diff from an existing file.

댓글 작성

게시글에 대한 의견을 남겨 주세요.

댓글 0