리눅스 명령어 정리..
1. ls
파일과 디렉토리 보기
형식 : ls [option]... [file]...
옵션에서 -옵션을 여러개를 넣을 수 있다.
사용예 : ls -als
option
-a : 디렉토리 내 모든 파일 출력
-i : 파일의 inode 출력
-l : 파일의 상세정보(크기, 소유자 등) 출력
-m : 파일의 가로출력
-s : 파일의 크기 출력
-t : 파일의 날짜순 출력
-F : 파일의 형태(링크, 소켓 등) 출력
-R : 서브디렉토리 포함하여 출력
--help : 도움말 출력
ls --help를 실행했을 때 도움말..
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'always' (default
if omitted), 'auto', or 'never'; more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files;
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group in a long listing, don't print group names
-h, --human-readable with -l and/or -s, print human readable sizes
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k, --kibibytes default to 1024-byte blocks for disk usage
-l use a long listing format
-L, --dereference when showing file information for a symbolic
link, show information for the file the link
references rather than for the link itself
-m fill width with a comma separated list of entries
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars print ? instead of nongraphic characters
--show-control-chars show nongraphic characters as-is (the default,
unless program is 'ls' and output is a terminal)
-Q, --quote-name enclose entry names in double quotes
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always,
shell-escape, shell-escape-always, c, escape
-r, --reverse reverse order while sorting
-R, --recursive list subdirectories recursively
-s, --size print the allocated size of each file, in blocks
-S sort by file size, largest first
--sort=WORD sort by WORD instead of name: none (-U), size (-S),
time (-t), version (-v), extension (-X)
--time=WORD with -l, show time as WORD instead of default
modification time: atime or access or use (-u);
ctime or status (-c); also use specified time
as sort key if --sort=time (newest first)
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, or +FORMAT;
FORMAT is interpreted like in 'date'; if FORMAT
is FORMAT1<newline>FORMAT2, then FORMAT1 applies
to non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time;
with -l: show access time and sort by name;
otherwise: sort by access time, newest first
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS set output width to COLS. 0 means no limit
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-Z, --context print any security context of each file
-1 list one file per line. Avoid '\n' with -q or -b
--help 이 도움말을 표시하고 끝냅니다
--version 버전 정보를 출력하고 끝냅니다
2.cat
파일의 내용을 출력하거나 리다이렉션으로 새로운 파일을 생성하는데 사용한다.
cat /폴더/파일이름
파일의 내용을 본다.
cat > 파일이름.확장자
현위치에서 파일 생성을 한다.
cat >> 파일이름.확장자
파일의 맨 아래에 입력된 내용을 추가한다.
내용을 추가하고 엔터를 누른 후 ctrl + d 를 누르면 내용이 저장되고 입력에서 빠져나옴.
사용법: cat [<옵션>]... [<파일>]...
Concatenate FILE(s) to standard output.
<파일>이 주어지지 않거나 - 이면 표준 입력을 읽습니다.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t -vT와 같음
-T, --show-tabs 탭 문자를 ^I로 표시합니다
-u (무시됨)
-v, --show-nonprinting ^ 와 M- 표기법을 사용합니다 (LFD와 TAB 제외)
--help 이 도움말을 표시하고 끝냅니다
--version 버전 정보를 출력하고 끝냅니다
예제:
cat f - g f 내용, 표준 입력, g 내용을 순서대로 출력.
cat 표준 입력을 표준 출력으로 복사.
3. cd
디렉토리 이동한다.
상대경로 이동 방법 : 현재 자신이 위치한 디렉토리로부터 시작하는 경로명을 지정하는 방법
절대경로 이동 방법 : 루트디렉토리로부터 시작하는 경로명을 지정하는 방법
사용법 :
cd . : 현재 디렉토리
cd .. : 바로 위 디렉토리로 이동.
cd /dir/: 해당 디렉토리로 이동한다.
cd or cd ~ : 홈 디렉토리로 이동한다.
4. chmod
파일이나 디렉토리의 권한을 변경한다.
리눅스의 모든파일에는 권한이란것이 있어서 파일의 소유자, 그룹, 다른사용자에게 모두 다른 권한을 줄 수 있다.
권한은 다음과 같은 형식으로 지정된다.
rwxrwxrwx
처음 rwx는 소유자, 가운데 rwx는 그룹, 마지막 rwx는 기타 사용자를 의미하고
r은 읽기, w는 쓰기, x는 실행을 의미한다. 허가 금지는 - 로 의미한다.
r = 4, w = 2, x = 1 , - = 0 의 숫자값을 가진다.
-u : 사용자
-g : 그룹
-o : 기타 사용자
-a : 모든 사용자
-+ : 허가 첨가
-- : 허가 삭제
-= : 해당 옵션은 모두 취소 (절대옵션)
-r : 읽기
-w : 쓰기
-x : 실행
예제:
chmod -R 777 /bin/su
/bin/su 폴더와 그 밑의 모든폴더와 파일에 사용자,그룹,다른사람 모두에게 읽기,쓰기,실행 권한을 준다.
chmod 707 /bin/su
/bin/su 폴더에 사용자(읽기,쓰기,실행), 그룹(권한없음), 다른사람(읽기,쓰기,실행) 권한을 준다.
chmod 755 /bin/su
/bin/su 폴더에 사용자(읽기,쓰기,실행), 그룹(읽기,실행), 다른사람(읽기,실행) 권한을 준다.
5. cp
파일 복사 명령, 여러 옵션으로 디렉토리도 복사가 가능
사용법 :
cp [옵션] [복사할파일] [이동할디렉토리]
-a : 파일의 속성, 링크 정보들을 그대로 유지하면서 복사한다.
-b : 이미 파일이 존재하면 백업 본을 만들고 복사한다.
-f : 기존의 파일을 강제로 삭제하고 복사한다.
-i : 덮어쓰기 전에 여부를 묻는다.
-p : 원본파일의 소유주, 그룹, 권한, 시간정보를 복사한다.
-r : 디렉토리를 복사한다.
6. rm
파일 삭제 명령, 여러 파일을 삭제하고자 할 때는 아스트릭(*)문자를 사용할 수 있다.
사용법 :
rm [옵션] [삭제할대상]
-i : 파일을 삭제하기 전 삭제 여부를 확인한다.
-f : 강제로 삭제한다.
-r : 파일이면 삭제하고 디렉토리일 경우 경로와 파일을 함께 삭제한다.
-v : 파일 지우는 정보를 자세하게 보여준다.
7. mv
파일을 이동 시키거나 이름을 변경한다.
사용법 :
mv [옵션] [원본파일명] [변경파일명]
mv [옵션] [원본파일명1]... [이동할디렉토리]
-i : 파일을 이동하기 전에 겹쳐쓰기 여부를 확인한다.
-f : 강제로 이동시킨다.
8.mkdir
새로운 디렉토리를 만든다.
사용법 :
mkdir [옵션] [생성하고자하는 디렉토리]
-p : 만들고자 하는 디렉토리의 하위 드렉토리를 동시에 만들 수 있다.
-m : 디렉토리를 만들면 서 접근 권한을 설정할 수 있다.
9.rmdir
디렉토리를 삭제하고자 할 때 사용한다.
사용법 :
rmdir [삭제할 디렉토리1] [삭제할 디렉토리2]....
10.pwd
현재 디렉토리를 보여준다.
'리눅스' 카테고리의 다른 글
tightvnc 설치 (0) | 2017.10.10 |
---|---|
우분투 코드이그나이터 index.php 사라지게 하기. (0) | 2017.08.31 |
리눅스 우분투 cli 부팅 (0) | 2017.07.24 |
vi 편집기 (0) | 2017.07.17 |
우분투 16.04 APM 설치. (0) | 2017.02.13 |