# ls --help
[root@worker ~]# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
-a, --all do not ignore entries starting with .
-d, --directory list directories themselves, not their contents
-h, --human-readable with -l and -s, print sizes like 1K 234M 2G etc.
-l use a long listing format
-r, --reverse reverse order while sorting
-R, --recursive list subdirectories recursively
-t sort by modification time, newest first
-X sort alphabetically by entry extension
예시
[root@worker ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg juyoung Music Pictures Public Templates Videos
[root@worker ~]# ls -a
. .ansible .bash_profile .config Desktop .esd_auth juyoung Pictures .ssh Videos
.. .bash_history .bashrc .cshrc Documents .ICEauthority .local .pki .tcshrc .viminfo
anaconda-ks.cfg .bash_logout .cache .dbus Downloads initial-setup-ks.cfg Music Public Templates .Xauthority
[root@worker ~]# ls -l
total 44
-rw-------. 1 root root 1985 Sep 5 13:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Desktop
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Documents
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Downloads
-rw-r--r--. 1 root root 2366 Sep 5 14:00 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 4096 Sep 13 22:02 juyoung
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Music
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Pictures
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Public
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Templates
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Videos
[root@worker ~]# ls -lh
total 44K
-rw-------. 1 root root 2.0K Sep 5 13:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Desktop
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Documents
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Downloads
-rw-r--r--. 1 root root 2.4K Sep 5 14:00 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 4.0K Sep 13 22:02 juyoung
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Music
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Pictures
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Public
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Templates
drwxr-xr-x. 2 root root 4.0K Sep 5 14:01 Videos
[root@worker ~]# ls -r
Videos Templates Public Pictures Music juyoung initial-setup-ks.cfg Downloads Documents Desktop anaconda-ks.cfg
[root@worker kubernetes]# ls -R
.:
kubeadm-client.conf kubelet.conf kubelet-config.yaml kubelet.env manifests pki ssl
./manifests:
./ssl:
ca.crt
[root@worker ~]# ls -lt
total 44
drwxr-xr-x. 2 root root 4096 Sep 13 22:02 juyoung
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Desktop
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Documents
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Downloads
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Music
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Pictures
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Public
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Templates
drwxr-xr-x. 2 root root 4096 Sep 5 14:01 Videos
-rw-r--r--. 1 root root 2366 Sep 5 14:00 initial-setup-ks.cfg
-rw-------. 1 root root 1985 Sep 5 13:56 anaconda-ks.cfg
[root@worker kubernetes]# ls -lX
total 24
drwxr-xr-x. 2 kube root 4096 Sep 19 15:10 manifests
lrwxrwxrwx. 1 root root 19 Sep 19 15:10 pki -> /etc/kubernetes/ssl
drwxr-xr-x. 2 kube root 4096 Sep 19 15:11 ssl
-rw-r--r--. 1 root root 435 Sep 19 15:11 kubeadm-client.conf
-rw-------. 1 root root 1955 Sep 19 15:11 kubelet.conf
-rw-r--r--. 1 root root 567 Sep 19 15:11 kubelet.env
-rw-r--r--. 1 root root 730 Sep 19 15:11 kubelet-config.yaml
# cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
or: cp [OPTION]... SOURCE... DIRECTORY
or: cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
-a, --archive same as -dR --preserve=all
--attributes-only don't copy the file data, just the attributes
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
--copy-contents copy contents of special files when recursive
-f, --force if an existing destination file cannot be
opened, remove it and try again (this option
is ignored when the -n option is also used)
-i, --interactive prompt before overwrite (overrides a previous -n
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST] preserve the specified attributes (default:
mode,ownership,timestamps), if possible
additional attributes: context, links, xattr,
all
-v, --verbose explain what is being done
예시
1) 파일 복사
// 현재 디렉토리에 있는 test1.txt 파일을 test2.txt라는 이름으로 현 위치에 복사
$ cp test1.txt test2.txt
// /home 경로의 test1.txt 파일을 test2.txt라는 이름으로 현재 위치에 복사
$ cp /home/test.txt test2.txt
// /home 경로의 test1.txt 파일을 test2.txt라는 이름으로 /root에 복사
$ cp /home/test1.txt /root/test2.txt
2) 디렉터리 복사
// 현재 위치에 있는 test1 디렉토리를 test2 디렉토리라는 이름으로 복사
$ cp -r test1 test2
3) 여러 파일을 한 번에 복사
// 현재 디렉터리에 있는 여러 파일을 /home에 복사
// $ cp [복사 대상1] [복사 대상2] [복사 대상3] ..... [복사 될 경로]
$ cp test1.txt test2.txt test3.txt /home
// 현재 위치에 있는 모든 파일을 /home에 복사
// $ cp * [복사 될 경로]
$ cp * /home
4) -v 옵션
[root@worker juyoung]# cp -v test1.txt test2.txt
'test1.txt' -> 'test2.txt'
5) -i 옵션
[root@worker juyoung]# cp -i test1.txt test2.txt
cp: overwrite 'test2.txt'?
# rm --help
Usage: rm [OPTION]... [FILE]...
Remove (unlink) the FILE(s).
-f, --force ignore nonexistent files and arguments, never prompt
-i prompt before every removal
-r, -R, --recursive remove directories and their contents recursively
-d, --dir remove empty directories
-v, --verbose explain what is being done
예시
1) -f 옵션 (파일 강제 삭제)
[root@worker juyoung]# rm -f test1.txt
2) -r 옵션 (디렉터리 삭제)
[root@worker juyoung]# rm -r test
3) -i 옵션
// 파일
[root@worker juyoung]# rm -i test1.txt
rm: remove regular file 'test1.txt'?
// 디렉터리
[root@worker juyoung]# rm -ir test
rm: descend into directory 'test'?
4) -d 옵션
// 디렉터리가 비어있는 경우
[root@worker juyoung]# rm -d empty/
rm: remove directory 'empty/'? y
// 디렉터리가 비어있지 않은 경우
[root@worker juyoung]# rm -d test
rm: cannot remove 'test': Directory not empty
4) -v 옵션
[root@worker juyoung]# rm -rfv test
removed 'test/test.txt'
removed directory 'test'
# mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force do not prompt before overwriting
-i, --interactive prompt before overwrite
-v, --verbose explain what is being done
// 현재 위치에 있는 test.txt 파일을 /home에 이동
$ mv test.txt /home
// 현재 위치에 있는 test.txt 파일을 /home에 text2.txt라는 이름으로 이동
$ mv test.txt /home/test2.txt
// 특정 위치에 있는 test.txt 파일을 다른 위치에 이동
$ mv /home/test.txt /root
2) 디렉터리 이동// 현재 위치에 있는 a 디렉터리를 b 디렉터리 내부로 이동
$ mv a b
// 특정 위치에 있는 a 디렉터리를 다른 위치에 이동
$ mv /home/a /root
3) 파일명 변경// 파일명 변경
$ mv test.txt test2.txt
// 현재 위치에 있는 test.txt 파일을 /home에 text2.txt라는 이름으로 이동
$ mv test.txt /home/test2.txt
4) -v 옵션[root@worker juyoung]# mv -v b a
renamed 'b' -> 'a/b'
# touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.
A FILE argument that does not exist is created empty, unless -c or -h
is supplied.
A FILE argument string of - is handled specially and causes touch to
change the times of the file associated with standard output.
-a change only the access time
-c, --no-create do not create any files
-m change only the modification time
-r, --reference=FILE use this file's times instead of current time
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time
--time=WORD change the specified time:
WORD is access, atime, or use: equivalent to -a
WORD is modify or mtime: equivalent to -m
예시
[root@worker juyoung]# touch a.txt
[root@worker juyoung]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 25 22:58 a.txt
// -m 옵션
[root@worker juyoung]# touch -m a.txt
[root@worker juyoung]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 25 22:59 a.txt
// -c 옵션
[root@worker juyoung]# touch -c a.txt
[root@worker juyoung]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 25 23:00 a.txt
// -r 옵션
[root@worker juyoung]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 25 23:00 a.txt
-rw-r--r--. 1 root root 0 Oct 25 23:01 b.txt
[root@worker juyoung]# touch -r a.txt b.txt
[root@worker juyoung]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 25 23:00 a.txt
-rw-r--r--. 1 root root 0 Oct 25 23:00 b.txt
참고: 2021 이기적 리눅스마스터 2급