리눅스 파일, 디렉토리 명령어(linux file/directory command) 1. basic
1. file & directory
1-1 file vs directory
- file: data container
- directory: specific file that contain file
therefore, file $\subset$ directroy
1-2 filename
- Available: alphabet, number, ‘-‘, ‘_’, ‘.’
- Forbidden: / (for delimiter between file/directory objects)
1-3 wildcard
- ? like $x$ (unknown) character, match with single char
match | mismatch | |
c? | c1 c2 ca | ac cat |
- [ ]
match with char in [ ]
match | mismatch | |
c[aeio] | ca ce ci co | cb ct |
c[a-d] | ca cb cc cd | ce cf |
c[a-e][0-9] | ca0 ce0 | cf0 cA- |
- *
match all string(including no char)
* | all files |
f* | all files started with 'f' |
*f | all files ended with 'f' |
*.* | all files contained '.' |
1-4 absolute vs relative path
- absolute path
- start from root(/) directory
- pathname started with ‘/’
- relative path
- start from working directory
- pathname not started with ‘/’
2. print working directory
pwd
3. list directory
ls
* options:
-l | long format |
-a | all file |
-i | inode number |
-F | append File indicator |
-R | Recursively |
-r | reverse |
4. touch
touch file
-
if file don’t exist: create file
-
if file exist: change atime, mtime, ctime
5. change directory
cd pathname
availabel absolute/relative pathname
6. make directory
mkdir dirname
* options:
mnemonic | command | functioning | |
-m | mode # | mkdir -m 700 dir1 | create directory name: "dir1" with mode 700 |
-p | parent | mkdir -p dir1/dir2/.. | create directory dir1, dir2, .. └ dir1 └ dir2 └ .. |
7. remove directory
rmdir dirname
Leave a comment