SlideShare a Scribd company logo
1 of 74
LINUX
COMMAND
장수경
Part 1 – Learning The Shell
Why use the command-line?
"Under Linux there are GUIs (graphical user interfaces), where you can point and click
and drag, and hopefully get work done without first reading lots of documentation. The
traditional Unix environment is a CLI (command line interface), where you type
commands to tell the computer what to do. That is faster and more powerful, but
requires finding out what the commands are."
https://help.ubuntu.com/community/UsingTheTerminal?action=show&redirect=BasicCommands
Start Terminal
Applications menu -> Accessories -> Terminal.
Keyboard Shortcut: Ctrl + Alt + T
Terminal Emulators
When using a graphical user interface, we need another program called a terminal emulator
to interact with the shell. If we look through our desktop menus, we will probably find
one. KDE uses konsole and GNOME uses gnome-terminal, though it's likely
called simply “terminal” on our menu. There are a number of other terminal emulators
available for Linux, but they all basically do the same thing; give us access to the shell.
You will probably develop a preference for one or another based on the number of bells
and whistles it has.
Shell Prompt
SHELL : 키보드로 입력한 명령어를 운영체계에 전달하여 이 명령어를 실행하게
하는 프로그램
# : root로 접속했을 경우 / sudo로 루트권한을 얻었을 경우
$ : 다른 유저로 접속했을 경우
username @ manchinename : working directory $
How Many Different Types of Shell Are There?
echo $SHELL
현재 사용중인 쉘 프로그램의 경로 출력
Linux에서는 대부분 bash 사용
chsh (change shell)
패스워드 입력 후 쉘 변경 가능
Debian Almquist shell (dash)
bourne again shell (bash)
korn (KSH)
csh/tsch
zsh
http://linux.about.com/cs/linux101/g/shell_command.htm
-echo $SHELL
현재 사용중인 쉘 프로그램의 경로 출력
Linux에서는 대부분 bash 사용
-chsh (change shell)
패스워드 입력 후 쉘 변경 가능
Ubuntu Directory
이와 같은 shell 명령어들은 일종의 실행파일, 프로그램이다.
단순한 명령어들은 built-in command라고 하여 bash shell에 아
예 내장되어 있는 경우도 있고,
그렇지 않은 경우 파일시스템 (루트 디렉토리)의 /bin 디렉토리 혹
은 /usr/bin 디렉토리에 모여있다. bin의 어원은 binary file. 컴퓨
터가 바로 실행할 수 있는 기계어 실행프로그램들이다. bin 디렉토
리에 들어가서 실행파일들 이름을 찬찬히 살펴보자. 리눅스 눈칫밥
3개월만 돼도 친숙한 이름들이 많이 보일 것이다.
일단 /bin 에는 좀 더 원초적이고 단순하며 저급한 명령어들이 모여
있다. 컴퓨터 구동에 필요한 최소한만 있다고 한다. 가령 rm
(remove), mkdir(make dir) 등등 정녕 이게 프로그램인가 싶은
기본적인 것들만 있다.
반면 /usr/bin에는 좀 고등한 것들이 많이 존재하는데, 가령 g++이
나 apt-get, w3m, nautilus과 같은 것들이 있다.
즉, 일반적으로 /bin에는 운영체제 기본 프로그램들이 모여
있고 /usr/bin에는 추가 프로그램들이 모여있다.
http://egloos.zum.com/ttti07/v/3512271
Command
[command] [argument1] [argument2]…
Command에 따라 사용가능한 argument의 형식 등이
다르다
• command의 동작 방법을 명시하는 option
• 파일이나 디렉토리의 이름/경로
• 임의의 문자열
• Etc…
- : 단축 옵션
-- : long 옵션
여러 옵션을 한 명령어에 연이어 사용할 수 있다
$ls -a -l wheel
ls는 command이고 -a, -l, wheel은 arguments
$ls -lt --reverse
man command
The man command is used to show you the manual of other commands. Try "man man" to
get the man page for man itself.
Searching for man files
If you aren't sure which command or application you need to use, you can try searching the man files.
•man -f foo(함수이름) searches only the titles of your system's man files. Try "man -f gnome", for example.
Note that this is the same as doing whatis command.
•man -k foo will search the man files for foo. Try "man -k nautilus" to see how this works. Note that this is the
same as doing apropos command.
Manipulating Files And Directories
1. ls, cd, pwd command
2. mkdir, rm command
3. cp command
4. wildcards
5. mv command
6. ln, touch command
1. ls, cd, pwd command
ls – directory listing
ls -al – formatted listing with hidden files
cd dir - change directory to dir
cd – change to home
Examples:
cd /home/user/docs/Letter.txt 절대주소
cd docs/Letter.txt 상대주소
cd / root로 이동
cd . 현재 디렉토리 유지
cd .. 상위 디렉토리로 이동
cd ~ or cd 홈 디렉토리로 이동
cd ~noname noname의 홈 디렉토리로 이동
cd - 이전 디렉토리로 이동
pwd – printing working directory
2. mkdir, rm command
mkdir dir – create a directory dir $ mkdir dir1 dir2
rm file – delete file
rm -r dir – delete directory dir
rm -f file – force remove file
rm -rf dir – force remove directory dir
3. cp command
cp file1 file2 – copy file1 to file2. file2가 이미 있다면 file1 내용을 그대로
덮어쓰게 된다. file2가 없으면 새로 생성된다.
cp -r dir1 dir2 – (--recursive) copy dir1 to dir2; create dir2 if it doesn't exist
디렉토리와 그 안의 내용까지 복사한다.
$ cp *.html destination
$ cp /etc/passwd .
4. wildcards
5. mv command
mv file1 file2 – rename or move file1 to file2
if file2 is an existing directory, moves file1 into directory file2
$ mv passwd fun
$ mv fun dir1
$ mv dir1/fun dir2
(dir1에 있는 fun파일을 dir2로 이동)
$ mv dir2/fun .
6. ln, touch command
ln -s file link – create symbolic link link to file $ ln –s fun fun-sym
$ ln –s ../fun dir1/fun-sym
touch file – create or update file
symbolic link
심볼릭 링크는 참조될 파일이나 디렉토리를 가리키는 텍스트 포인터가 포함된 특수한 파일을 생성
한다. 이러한 점에서 윈도우의 바로가기와 매우 흡사한 방식이다.
심볼릭 링크가 참조하고 있는 파일과 심볼릭 링크 그 자체는 서로 구분하기 힘들 정도다. 예를 들면,
심볼릭 링크에 편집을 하게 되면 심볼릭 링크가 참조하고 있는 파일도 역시 똑같은 변경이 이루어진
다. 하지만 심볼릭 링크를 삭제하는 경우엔 그 링크만 삭제되고 파일은 남아있다. 심볼릭 링크를 삭
제하기 전에 파일을 지웠다면 심볼릭 링크는 살아있지만 이 링크는 아무것도 가리키지 않게 된다. 이
러한 경우를 링크가 깨졌다고 표현한다.
많은 쉘에서 ls 명령어로 인해 빨간색이나 다른 색상으로 깨진 링크를 볼 수 있다.
Redirection
1. Redirecting Standard Input, Output, And Error- cat command
2. pipelines
3. Filters - uniq, wc, grep, cut, paste, join, head, tail, tee command
In this lesson we are going to unleash what may be the coolest feature of the command
line. It's called I/O redirection (입출력 방향지정). The “I/O” stands for input/output and with
this facility you can redirect(재지정) the input and output of commands to and from files, as
well as connect multiple commands together into powerful command pipelines.
1. Standard Input, Output, And Error
programs such as ls actually send their results to a special file called standard output
(often expressed as stdout) and their status messages to another file called standard
error (stderr). By default, both standard output and standard error are linked to the
screen and not saved into a disk file.
In addition, many programs take input from a facility called standard input (stdin) which
is, by default, attached to the keyboard.
Redirecting Standard Output
I/O redirection allows us to redefine where standard output goes. To redirect standard
output to another file instead of the screen, we use the “>” redirection operator
followed by the name of the file.
$ ls -l /usr/bin > ls-output.txt
$ ls -l ls-output.txt
$ less ls-output.txt
$ ls -l /bin/usr > ls-output.txt 오류메세지만을 만들기 때문에 크기가 0인 파일로 덮어씀
$ > ls-output.txt 위 원리를 이용하여 새로운 빈 파일을 만들거나 파일을 잘라냄
$ ls -l /usr/bin >> ls-output.txt 출력할 내용을 파일에 이어서 작성, 존재하지 않는 파일이
면 파일 생성
Redirecting Standard Error
Redirecting standard error lacks the ease of a dedicated redirection operator. To redirect
standard error we must refer to its file descriptor. A program can produce output on any
of several numbered file streams. While we have referred to the first three of these file
streams as standard input, output and error, the shell references them internally as file
descriptors 0, 1 and 2, respectively. The shell provides a notation for redirecting files
using the file descriptor number. Since standard error is the same as file descriptor
number 2, we can redirect standard error with this notation:
$ ls -l /bin/usr 2> ls-error.txt
The file descriptor “2” is placed immediately before the redirection operator to perform
the redirection of standard error to the file ls-error.txt.
Redirecting Standard Output And Standard Error To One File
$ ls -l /bin/usr > ls-output.txt 2>&1
Using this method, we perform two redirections. First we redirect standard output to the
file ls-output.txt and then we redirect file descriptor 2 (standard error) to file
descriptor one (standard output) using the notation 2>&1.
or
$ ls -l /bin/usr &> ls-output.txt
Disposing Of Unwanted Output
This “/dev/null” file is
a system device called a bit bucket which accepts input and does nothing with it.
$ ls -l /bin/usr 2> /dev/null
Redirecting Standard Input- cat command
cat [file...]- Concatenate files and print on the standard output 파일과 표준 출력을 연결
하나이상의 파일을 읽어들여서 표준 출력으로 그 내용을 복사
주로 짧은 텍스트 파일을 표시할 때, 여러 파일을 하나로 합칠 때
$ cat ls-output.txt
Say we have downloaded a large file that has been split into multiple parts (multimedia files are
often split this way on Usenet), and we want to join them back together. If the files were named:
movie.mpeg.001 movie.mpeg.002 ... movie.mpeg.099
we could join them back together with this command:
$ cat movie.mpeg.0* > movie.mpeg
$ cat > lazy_dog.txt
The quick brown fox jumped over the lazy dog.
텍스트 입력 후 CTRL-D
2. Pipelines
Using the pipe operator “|” (vertical bar), the standard output of one command can be piped into the standard
input of another: command1 | command2
$ ls -l /usr/bin | less
more, less – output the contents of file
3. Filters - uniq, grep, wc command
Pipelines are often used to perform complex operations on data. It is possible to put several commands
together into a pipeline. Frequently, the commands used this way are referred to as filters. Filters take
input, change it somehow and then output it.
sort - Sort lines of text
uniq - Report or omit repeated lines
$ ls /bin /usr/bin | sort | uniq | less 중복된 내용 삭제
$ ls /bin /usr/bin | sort | uniq -d | less 중복된 내용 표시
grep - Print lines matching a pattern (“-i” : 대소문자 구분안함, “-v” : 패턴과 일치하지않는 것 출력)
$ ls /bin /usr/bin | sort | uniq | grep zip
wc (word count) - Print newline, word, and byte counts for each file
$ wc ls-output.txt
7902 64566 503634 ls-output.txt
$ ls /bin /usr/bin | sort | uniq | wc –l 정렬된 목록에서 항목개수 ( -l :line 수만)
3. Filters – cut, paste, join command
cut – Remove sections from each line of files
paste – Merge lines of files
join – Join lines of two files on a common field
(참고) awk – 행 단위로 텍스트 파일을 편집
3. Filters - head, tail, tee command
head - Output the first part of a file 앞 10줄
tail – Output the last part of a file 뒤 10줄
$ head -n 5 ls-output.txt 앞 5줄
tail -f file – output the contents of file as it grows, starting with the last 10 lines
$ tail -f /var/log/messages 실시간으로 로그 파일 확인, CTRL-C 누를 때까지 계속
tee - Read from standard input and write to standard output and files
작업이 진행되고 있을 때 중간 지점의 파이프라인에 있는 내용을 알고 싶을 때 유용
$ ls /usr/bin | tee ls.txt | grep zip
Expansion & Quoting
1. Expansion
2. Quoting
1. Expansion
Each time you type a command line and press the enter key, bash performs several
processes upon the text before it carries out your command. We have seen a couple
of cases of how a simple character sequence, for example “*”, can have a lot of meaning
to the shell. The process that makes this happen is called expansion.
echo – Display a line of text
$ echo this is a test
this is a test
Pathname Expansion 경로명 확장 (와일드카드로 동작하는 방식)
$ echo *
Desktop Documents ls-output.txt Music Pictures Public Templates Videos
1. Expansion
Tilde(~) Expansion 틸드 확장
$ echo ~ 홈 디렉토리
/home/me
Arithmetic Expansion 산술 확장
$ echo $((2 + 2))
4
$ echo $(($((5**2)) * 3))
75
1. Expansion
Brace Expansion 중괄호 확장
$ echo Front-{A,B,C}-Back
Front-A-Back Front-B-Back Front-C-Back
$ echo {001..15}
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015
Parameter Expansion 매개변수 확장
$ echo $USER 사용자명 표시
$ printenv | less 사용가능한 변수목록 보기
Command Substitution 명령어 치환
which – show which app will be run by default 실행프로그램의 위치 표시
$ ls -l $(which cp) or ls -l `which cp` 경로명 전체를 알지 못해도 cp 프로그램 내용볼수있다
-rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp
$ file $(ls -d /usr/bin/* | grep zip)
2. Quoting
Double Quotes
쉘에서 사용하는 특수한 기호들이 가진 의미가 없어지고 대신 일반적인 문자들로 인식
단, $,,’ 기호는 예외
즉 단어분할(공백삭제), 경로명 확장, 틸드 확장, 괄호 확장을 숨길 수 있지만 매개변수 확
장, 산술 확장, 명령어 치환은 그대로 시행
$ ls -l two words.txt
ls: cannot access two: No such file or directory
ls: cannot access words.txt: No such file or directory
$ ls -l "two words.txt"
-rw-rw-r-- 1 me me 18 2008-02-20 13:03 two words.txt
2. Quoting
Single Quotes
$ echo text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER
text /home/me/ls-output.txt a b foo 4 me
$ echo "text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER"
text ~/*.txt {a,b} foo 4 me
$ echo 'text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER'
text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER
Escaping Characters (backslash)
$ mv bad&filename good_filename
Advanced Keyboard Tricks
1. Command line editing
2. Completion
3. Using history
1. Command Line Editing
2. Completion
Completion 자동완성 : 탭키
3. Using History
$ history | less
By default, bash stores the last 500 commands you have entered.
$ history | grep /usr/bin
88 ls -l /usr/bin > ls-output.txt
The number “88” is the line number of the command in the history list. We could use this
immediately using another type of expansion called history expansion.
$ !88
Permission
$ ls -l foo.txt
-rw-rw-r-- 1 me me 0 2008-03-06 14:52 foo.txt
Permission
Permission
id – Display user identity
chmod – Change a file's mode 파일소유자나 슈퍼유저만이 가능
(1) 8진법
$ chmod 600 foo.txt
$ ls -l foo.txt
-rw------- 1 me me 0 2008-03-06 14:52 foo.txt
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world
4 – read (r)
2 – write (w)
1 – execute (x)
Permission
(2) Symbolic Notation (참고)
Permission
umask – Set the default file permissions
su – Run a shell as another user
sudo – Execute a command as another user
chown – Change a file's owner
passwd - Changing a password
Permission
sudo command
How do you use sudo !!? Simply. Imagine you have entered the following command:
$apt-get install ranger
The words "Permission denied" will appear unless you are logged in with elevated privileges.
This elevates privileges to the root-user administrative level temporarily, which is necessary
when working with directories or files not owned by your user account.
sudo !! runs the previous command as sudo. So the previous command now becomes:
$sudo apt-get install ranger
Logging in as another user (Please don't use this to become root)
$sudo -i -u <username>
Enabling the root account
$sudo -i
To enable the root account (i.e. set a password) use:
$sudo passwd root
Enabling the root account is rarely necessary. Almost everything you need to do as administrator of an
Ubuntu system can be done via sudo or gksudo. If you really need a persistent root login, the best
alternative is to simulate a root login shell using the following command...
Process
ps – display your currently active processes
TTY(teletype) : the controlling
terminal for the process
Process
top ('table of processes') – display all running processes
jobs – List active jobs
bg – lists stopped or background jobs;
resume a stopped job in the background
fg – brings the most recent job to foreground
fg n – brings job n to the foreground
kill – Send a signal to a process
$ kill 28401 프로세스 종료
[1]+ Terminated xlogo
작업번호1인 xlogo 프로그램을 종료함
killall – Kill processes by name
shutdown – Shutdown or reboot the system
Part 2 – Configuration And The
Environment
The Environment
What Is Stored In The Environment?
The shell stores two basic types of data in the environment, though, with bash, the
types are largely indistinguishable. They are environment variables and shell variables.
Shell variables are bits of data placed there by bash, and environment variables are basically everything else.
In addition to variables, the shell variables also stores some programmatic data, namely aliases and shell
functions.
The Environment
alias – Create an alias for a command
$ alias
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias –showdot --show-tilde'
The Environment
How Is The Environment Established?
What's A Startup File And What’s In That?
When we log on to the system, the bash program
starts, and reads a series of configuration scripts
called startup files, which define the default
environment shared by all users.
If the file "~/.bashrc" exists,
then
read the "~/.bashrc" file.
The Environment
Modifying The Environment
$ cp .bashrc .bashrc.bak 만약을 위해 백업파일 만듬
$ nano .bashrc nano 편집기로 다음 내용을 추가
# Change umask to make directory sharing easier
umask 0002
# Ignore duplicates in command history and increase
# history size to 1000 lines
export HISTCONTROL=ignoredups
export HISTSIZE=1000
# Add some helpful aliases
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto‘
Ctrl-o : save, Ctrl-x : exit nano
$ source .bashrc 변경사항 적용
=. .bashrc
VIM editor
VIM editor
* 입력 명령어
i 현재 커서 위치에 삽입(왼쪽) a 현재 커서 위치 다음에 삽입
o 현재 커서가 위치한 줄의 아랫줄에 삽입 O 현재 커서가 위치한 줄의 바로 위에 삽입
I 현재 커서가 위치한 줄의맨 앞에 삽입 A 현재 커서가 위치한 줄의 맨 뒤에 삽입
* 지우기 명령어
x 현재 커서 위치의 문자를 삭제 dd 현재 커서가 위치한 줄을 삭제
dw 현재 커서가 위치한 단어를 삭제 d$ 현재 커서가 위치한 곳부터 그 행의 끝까지 삭제
dG 현재 커서가 위치한 행부터 편집문서의 마지막 줄까지 삭제
*. 삭제한 내용은 바로 지워지지 않고 버퍼에 저장되므로 붙여넣기 하거나 취소 할 수 있다.
* 복사하기와 붙이기
yy(=Y) 현재 커서가 위치한 줄을 버퍼에 복사(nyy => 현재 커서가 위치한 곳부터 아래로 n 라인을 버퍼에 복사한다)
yw 현재 커서가 위치한 단어를 버퍼에 복사(nyw => 현재 커서가 위치한 단어부터 오른쪽으로 n개의 단어를 버퍼에 복사한다)
p 버퍼에 들어 있는 내용을 현재 커서가 위치한 줄의 아래에 붙이기
P 버퍼에 들어 있는 내용을 현재 커서가 위치한 줄의 위에 붙이기
* 치환
r 현재 위치의 문자를 한개만 바꾼다.
R 현재 커서위치에서 오른쪽으로 esc 키를 입력할 때 까지 바꾼다.
cw 현재 위치의 단어를 바꾼다.
cc 현재 커서가 위치한 줄을 바꾼다.
C 현재 커서가 위치한 곳으로부터 줄의 끝까지 바꾼다.
~ 대소문자를 서로 바꾼다.
* 취소 명령어
u 방금 한 명령을 취소한다.
U 현재 커서가 위치한 줄에 대한 편집 명령을 취소한다.
^R (=redo) 취소한 명령을 다시 취소 (vim)
. 방금한 명령을 되풀이 한다.
VIM editor
* 이동 명령어 정리
^b(back) 한 화면 위로 이동 ^u(up) 반 화면 위로 이동
^f(forward) 한 화면 아래로 이동 ^d(down) 반 화면 아래로 이동
e 한 단어 뒤로 이동 b 한 단어 앞으로 이동
0 줄의 제일 처음부터 이동 $ 줄의 제일 끝으로 이동
VIM editor
스크립트 작성을 용이하게 해주는 옵션
:syntax on 구문 강조 기능. 쉘 구문마다 다른 색상으로 표시해주기 때문에 프로그래밍 오류
를 쉽게 찾아낼 수 있다. vim editor의 풀버전이 설치되어 있어야 한다.
:set hlsearch 검색 결과를 강조하여 표시.
:set autoindent 자동 들여쓰기 기능. 사용하지 않으려면 CTRL-D
이 옵션들을 영구적으로 적용하려면 ~/.vimrc 파일에 이 옵션을 추가(콜론기호는 제외하고 입력)
Part 3 – Common Tasks And Essential
Tools
Networking
Network
ping host – ping host and output results 네트워크 호스트로 고유 패킷(IMCP ECHO-REQUEST) 전송
whois domain – get whois information for domain
dig domain – get DNS information for domain
dig -x host – reverse lookup host
wget file – download file
$wget http://sourceforge.net/projects/antix-linux/files/Final/MX-krete/antiX-15-V_386-full.iso/download
wget -c file – continue a stopped download
SSH(Secure Shell)
ssh user@host – connect to host as user 원격호스트와 안전하게 통신
ssh -p port user@host – connect to host on port as user
ssh-copy-id user@host – add your key to host for user to enable a keyed or
passwordless login
Searching
locate – Find files by name 파일명으로 파일 찾기
$ locate bin/zip zip으로 시작하는 프로그램(명령어)찾기
$ locate zip | grep bin zip 문자열이 포함된 프로그램 찾기
find – Search for files in a directory hierarchy
주어진 디렉토리 트리내에서 특정조건에 부합하는 파일 검색하기
$ find ~ -type d | wc –l -type d:검색결과에서 디렉토리 목록만 보기
Searching
$ find ~ ( -type f -not -perm 0600 ) -or ( -type d -not -perm 0700 )
파일들의 퍼미션이 0600으로 설정되어 있지 않거나 디렉토리의 퍼미션이 0700으로 설정되어 있지 않은지 확인
$ find ~ -type f -name '*.BAK' –delete 백업파일 확장자를 가진 파일을 삭제
Archiving And Backup
Compressing Files 파일 압축하기
gzip file – compresses file and renames it to file.gz
gzip -d file.gz – decompresses file.gz back to file
bzip2 file – 속도는 느리지만 고성능 압축
zip –r file.zip file – zip파일로 압축. 윈도우 시스템과 파일을 교환할때 (-r: 하위디렉토리 포함)
Archiving Files 파일 보관하기(많은 파일들을 모아서 하나의 큰 파일로 묶는 과정)
tar cf file.tar files – create a tar(tape archive) named file.tar containing files
tar xf file.tar – extract the files from file.tar 아카이브 해제
tar czf file.tar.gz files – create a tar with Gzip compression
tar xzf file.tar.gz – extract a tar using Gzip
tar cjf file.tar.bz2 – create a tar with Bzip2 compression
tar xjf file.tar.bz2 – extract a tar using Bzip2
f : 아카이브의 이름을 지정
Regular Expressions
Simply put, regular expressions are symbolic notations used to identify patterns in
text. In some ways, they resemble the shell’s wildcard method of matching file and
pathnames, but on a much grander scale.
http://coffeenix.net/doc/regexp/node17.html
[^bg] 괄호표현식 안의 ^는 부정의 의미, ^[A-Z] 괄호표현식안의 –는 문자범위
Regular Expressions
http://regexr.com/
정규 표현식에 대한 도움말과 각종 사례들을
보여주는 서비스로 정규표현식을 라이브로
만들 수 있는 기능도 제공하고 있다.
Regular Expressions
https://www.blackbagtech.com/blog/2013/05/08/digital-forensics-regular-expressions-regex-%E2%80%93-part-two/
Regular Expressions
Compiling Programs
Simply put, compiling is the process of translating source code (the human-readable description of a
program written by a programmer) into the native language of the computer’s processor.
The computer’s processor (or CPU) works at a very elemental level, executing programs
in what is called machine language. This is a numeric code that describes very small operations, such as
“add this byte,” “point to this location in memory,” or “copy this byte.” Each of these instructions is expressed
in binary (ones and zeros).
This problem was overcome by the advent of assembly language, which replaced the numeric codes with
(slightly) easier to use character mnemonics such as CPY (for copy) and MOV (for move). Programs written
in assembly language are processed into machine language by a program called an assembler. Assembly
language is still used today for
certain specialized programming tasks, such as device drivers and embedded systems.
Compiling Programs
We next come to what are called high-level programming languages. They are called this because they allow the
programmer to be less concerned with the details of what the processor is doing and more with solving the problem
at hand.
While there are many popular programming languages, two predominate. Most programs
written for modern systems are written in either C or C++. In the examples to follow, we will be compiling a C
program.
Programs written in high-level programming languages are converted into machine language
by processing them with another program, called a compiler. Some compilers translate high-level instructions into
assembly language and then use an assembler to perform the final stage of translation into machine language.
A process often used in conjunction with compiling is called linking. There are many common tasks performed by
programs. Take, for instance, opening a file. Many programs perform this task, but it would be wasteful to have
each program implement its own routine to open files. It makes more sense to have a single piece of programming
that knows
how to open files and to allow all programs that need it to share it. Providing support for common tasks is
accomplished by what are called libraries. They contain multiple routines, each performing some common task that
multiple programs can share. If we look in the /lib and /usr/lib directories, we can see where many of them live. A
program called a linker is used to form the connections between the output of the compiler and the libraries that the
compiled program requires. The final result of this process is the executable program file, ready for use.
Compiling Programs
There are programs such as shell scripts that do not require compiling.
They are executed directly. These are written in what are known as scripting or interpreted languages.
These languages have grown in popularity in recent years and include Perl, Python, PHP, Ruby, and many
others.
Scripted languages are executed by a special program called an interpreter. An interpreter inputs the
program file and reads and executes each instruction contained within it. In general, interpreted programs
execute much more slowly than compiled programs. This is because that each source code instruction in an
interpreted program is translated every time it is carried out, whereas with a compiled program, a source
code instruction is only translated once, and this translation is permanently recorded in the final
executable file.
Compiling Programs
Install from source:
./configure
make
make install
make – Utility to maintain programs
Part 4 – Writing Shell Scripts
Writing Shell Script
In the simplest terms, a shell script is a file containing a series of commands. The shell
reads this file and carries out the commands as though they have been entered directly on the
command line.
The shell is somewhat unique, in that it is both a powerful command line interface to the
system and a scripting language interpreter.
Writing Shell Script
How To Write A Shell Script
To successfully create and run a shell script, we need to do three things:
1. Write a script. Shell scripts are ordinary text files. So we need a text editor to
write them. The best text editors will provide syntax highlighting, allowing us to
see a color-coded view of the elements of the script. Syntax highlighting will help
us spot certain kinds of common errors. vim, gedit, kate, and many other editors
are good candidates for writing scripts.
2. Make the script executable. The system is rather fussy about not letting any old
text file be treated as a program, and for good reason! We need to set the script
file’s permissions to allow execution.
3. Put the script somewhere the shell can find it. The shell automatically searches
certain directories for executable files when no explicit pathname is specified. For
maximum convenience, we will place our scripts in these directories.
Writing Shell Script
1. Write a script.
#!/bin/bash
# This is our first script.
echo 'Hello World!'
2. Make the script executable.
$ ls -l hello_world
-rw-r--r-- 1 me me 63 2009-03-07 10:10 hello_world
$ chmod 755 hello_world
$ ls -l hello_world
-rwxr-xr-x 1 me me 63 2009-03-07 10:10 hello_world
3. Put the script somewhere the shell can find it.
In order for the script to run, we must precede the script name with an explicit path.
$ ./hello_world
$ mkdir bin ~/bin 디렉토리는 개인적인 용도로 사용하려는 스크립트를 저장하기에 적합한 장소
$ mv hello_world bin
$ hello_world
Hello World!
#!(shebang)
뒤따라오는 스크립트를 실행하기 위한 인터프리
터의 이름을 시스템에 알려준다.
모든 쉘 스크립트 첫줄에 반드시 존재해야 한다.
Part 5 – etc..
Shortcuts
Ctrl+C – halts the current command
Ctrl+Z – stops the current command, resume with
fg in the foreground or bg in the background
Ctrl+D – log out of current session, similar to exit
Ctrl+W – erases one word in the current line
Ctrl+U – erases the whole line
Ctrl+R – type to bring up a recent command
!! - repeats the last command
exit – log out of current session
Ctrl+K - Cuts text from the cursor
until the end of the line
Ctrl+Y - Pastes text
Ctrl+E or End - Move cursor to end of line
Ctrl+A or Home - Move cursor to
the beginning of the line
ALT+F - Jump forward to next space
ALT+B - Skip back to previous space
ALT+Backspace - Delete previous word
Ctrl+W - Cut word behind cursor
Shift+Insert - Pastes text into terminal
Happy New Year !
Get Your Fortune Told
Another one that isn't particularly useful but just a bit of fun is the fortune command.
Like the sl command you might need to install it from your repository first.
sudo apt-get install fortune-mod
Then simply type the following to get your fortune told
fortune
Get A Cow To Tell Your Fortune
Finally get a cow to tell you your fortune using cowsay.
Type the following into your terminal:
fortune | cowsay
If you have a graphical desktop you can use xcowsay to get a cartoon cow to show your fortune:
fortune | xcowsay
cowsay and xcowsay can be used to display any message.
For example to display "Hello World" simply use the following command:
cowsay "hello world"
http://linux.about.com/od/commands/tp/11-Linux-Terminal-Commands-That-Will-Rock-Your-World.01.htm
https://www.digitalocean.com/community/tutorials/top-10-linux-easter-eggs
Reference
http://linuxcommand.org/tlcl.php
http://files.fosswire.com/2007/08/fwunixref.pdf

More Related Content

What's hot

Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structureSreenatha Reddy K R
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)raj upadhyay
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overviewAmeer Sameer
 
Basic commands
Basic commandsBasic commands
Basic commandsambilivava
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbookWave Digitech
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)meashi
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity TipsKeith Bennett
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Scriptsbmguys
 
Unix command line concepts
Unix command line conceptsUnix command line concepts
Unix command line conceptsArtem Nagornyi
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformaticsBonnie Ng
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linuxshravan saini
 

What's hot (20)

Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
 
Basic commands
Basic commandsBasic commands
Basic commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Basic Linux commands
Basic Linux commandsBasic Linux commands
Basic Linux commands
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity Tips
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Unix command line concepts
Unix command line conceptsUnix command line concepts
Unix command line concepts
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Linux class 8 tar
Linux class 8   tar  Linux class 8   tar
Linux class 8 tar
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 

Viewers also liked

Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line BasicsWe Ihaveapc
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumarymentorsnet
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014iimjobs and hirist
 

Viewers also liked (6)

Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line Basics
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumary
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
 

Similar to Linux command for beginners

linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.pptLuigysToro
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command ShellTushar B Kute
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.pptKiranMantri
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdfharikrishnapolaki
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsBITS
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to LinuxDimas Prasetyo
 
Linux Notes-1.pdf
Linux Notes-1.pdfLinux Notes-1.pdf
Linux Notes-1.pdfasif64436
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to UnixSudharsan S
 
bash_1_2021-command line introduction.pdf
bash_1_2021-command line introduction.pdfbash_1_2021-command line introduction.pdf
bash_1_2021-command line introduction.pdfMuhammadAbdullah311866
 
Linux Cheat Sheet.pdf
Linux Cheat Sheet.pdfLinux Cheat Sheet.pdf
Linux Cheat Sheet.pdfroschahacker
 
Using Unix
Using UnixUsing Unix
Using UnixDr.Ravi
 

Similar to Linux command for beginners (20)

linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
 
Linux
LinuxLinux
Linux
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux Notes-1.pdf
Linux Notes-1.pdfLinux Notes-1.pdf
Linux Notes-1.pdf
 
Linux
LinuxLinux
Linux
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
3. intro
3. intro3. intro
3. intro
 
Shell intro
Shell introShell intro
Shell intro
 
Shell intro
Shell introShell intro
Shell intro
 
bash_1_2021-command line introduction.pdf
bash_1_2021-command line introduction.pdfbash_1_2021-command line introduction.pdf
bash_1_2021-command line introduction.pdf
 
Linux Cheat Sheet.pdf
Linux Cheat Sheet.pdfLinux Cheat Sheet.pdf
Linux Cheat Sheet.pdf
 
cisco
ciscocisco
cisco
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
 

Recently uploaded

Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringPrajakta Shinde
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...Universidade Federal de Sergipe - UFS
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024innovationoecd
 
FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naJASISJULIANOELYNV
 
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPirithiRaju
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxmalonesandreagweneth
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationColumbia Weather Systems
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxNandakishor Bhaurao Deshmukh
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》rnrncn29
 
Topic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxTopic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxJorenAcuavera1
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
Functional group interconversions(oxidation reduction)
Functional group interconversions(oxidation reduction)Functional group interconversions(oxidation reduction)
Functional group interconversions(oxidation reduction)itwameryclare
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...lizamodels9
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical Engineering
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024
 
FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by na
 
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdfPests of jatropha_Bionomics_identification_Dr.UPR.pdf
Pests of jatropha_Bionomics_identification_Dr.UPR.pdf
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather Station
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
 
Topic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptxTopic 9- General Principles of International Law.pptx
Topic 9- General Principles of International Law.pptx
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
Functional group interconversions(oxidation reduction)
Functional group interconversions(oxidation reduction)Functional group interconversions(oxidation reduction)
Functional group interconversions(oxidation reduction)
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
 

Linux command for beginners

  • 2. Part 1 – Learning The Shell
  • 3. Why use the command-line? "Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are." https://help.ubuntu.com/community/UsingTheTerminal?action=show&redirect=BasicCommands
  • 4. Start Terminal Applications menu -> Accessories -> Terminal. Keyboard Shortcut: Ctrl + Alt + T Terminal Emulators When using a graphical user interface, we need another program called a terminal emulator to interact with the shell. If we look through our desktop menus, we will probably find one. KDE uses konsole and GNOME uses gnome-terminal, though it's likely called simply “terminal” on our menu. There are a number of other terminal emulators available for Linux, but they all basically do the same thing; give us access to the shell. You will probably develop a preference for one or another based on the number of bells and whistles it has.
  • 5. Shell Prompt SHELL : 키보드로 입력한 명령어를 운영체계에 전달하여 이 명령어를 실행하게 하는 프로그램 # : root로 접속했을 경우 / sudo로 루트권한을 얻었을 경우 $ : 다른 유저로 접속했을 경우 username @ manchinename : working directory $
  • 6. How Many Different Types of Shell Are There? echo $SHELL 현재 사용중인 쉘 프로그램의 경로 출력 Linux에서는 대부분 bash 사용 chsh (change shell) 패스워드 입력 후 쉘 변경 가능 Debian Almquist shell (dash) bourne again shell (bash) korn (KSH) csh/tsch zsh http://linux.about.com/cs/linux101/g/shell_command.htm -echo $SHELL 현재 사용중인 쉘 프로그램의 경로 출력 Linux에서는 대부분 bash 사용 -chsh (change shell) 패스워드 입력 후 쉘 변경 가능
  • 7. Ubuntu Directory 이와 같은 shell 명령어들은 일종의 실행파일, 프로그램이다. 단순한 명령어들은 built-in command라고 하여 bash shell에 아 예 내장되어 있는 경우도 있고, 그렇지 않은 경우 파일시스템 (루트 디렉토리)의 /bin 디렉토리 혹 은 /usr/bin 디렉토리에 모여있다. bin의 어원은 binary file. 컴퓨 터가 바로 실행할 수 있는 기계어 실행프로그램들이다. bin 디렉토 리에 들어가서 실행파일들 이름을 찬찬히 살펴보자. 리눅스 눈칫밥 3개월만 돼도 친숙한 이름들이 많이 보일 것이다. 일단 /bin 에는 좀 더 원초적이고 단순하며 저급한 명령어들이 모여 있다. 컴퓨터 구동에 필요한 최소한만 있다고 한다. 가령 rm (remove), mkdir(make dir) 등등 정녕 이게 프로그램인가 싶은 기본적인 것들만 있다. 반면 /usr/bin에는 좀 고등한 것들이 많이 존재하는데, 가령 g++이 나 apt-get, w3m, nautilus과 같은 것들이 있다. 즉, 일반적으로 /bin에는 운영체제 기본 프로그램들이 모여 있고 /usr/bin에는 추가 프로그램들이 모여있다. http://egloos.zum.com/ttti07/v/3512271
  • 8. Command [command] [argument1] [argument2]… Command에 따라 사용가능한 argument의 형식 등이 다르다 • command의 동작 방법을 명시하는 option • 파일이나 디렉토리의 이름/경로 • 임의의 문자열 • Etc… - : 단축 옵션 -- : long 옵션 여러 옵션을 한 명령어에 연이어 사용할 수 있다 $ls -a -l wheel ls는 command이고 -a, -l, wheel은 arguments $ls -lt --reverse
  • 9. man command The man command is used to show you the manual of other commands. Try "man man" to get the man page for man itself. Searching for man files If you aren't sure which command or application you need to use, you can try searching the man files. •man -f foo(함수이름) searches only the titles of your system's man files. Try "man -f gnome", for example. Note that this is the same as doing whatis command. •man -k foo will search the man files for foo. Try "man -k nautilus" to see how this works. Note that this is the same as doing apropos command.
  • 10. Manipulating Files And Directories 1. ls, cd, pwd command 2. mkdir, rm command 3. cp command 4. wildcards 5. mv command 6. ln, touch command
  • 11. 1. ls, cd, pwd command ls – directory listing ls -al – formatted listing with hidden files cd dir - change directory to dir cd – change to home Examples: cd /home/user/docs/Letter.txt 절대주소 cd docs/Letter.txt 상대주소 cd / root로 이동 cd . 현재 디렉토리 유지 cd .. 상위 디렉토리로 이동 cd ~ or cd 홈 디렉토리로 이동 cd ~noname noname의 홈 디렉토리로 이동 cd - 이전 디렉토리로 이동 pwd – printing working directory
  • 12. 2. mkdir, rm command mkdir dir – create a directory dir $ mkdir dir1 dir2 rm file – delete file rm -r dir – delete directory dir rm -f file – force remove file rm -rf dir – force remove directory dir
  • 13. 3. cp command cp file1 file2 – copy file1 to file2. file2가 이미 있다면 file1 내용을 그대로 덮어쓰게 된다. file2가 없으면 새로 생성된다. cp -r dir1 dir2 – (--recursive) copy dir1 to dir2; create dir2 if it doesn't exist 디렉토리와 그 안의 내용까지 복사한다. $ cp *.html destination $ cp /etc/passwd .
  • 15. 5. mv command mv file1 file2 – rename or move file1 to file2 if file2 is an existing directory, moves file1 into directory file2 $ mv passwd fun $ mv fun dir1 $ mv dir1/fun dir2 (dir1에 있는 fun파일을 dir2로 이동) $ mv dir2/fun .
  • 16. 6. ln, touch command ln -s file link – create symbolic link link to file $ ln –s fun fun-sym $ ln –s ../fun dir1/fun-sym touch file – create or update file symbolic link 심볼릭 링크는 참조될 파일이나 디렉토리를 가리키는 텍스트 포인터가 포함된 특수한 파일을 생성 한다. 이러한 점에서 윈도우의 바로가기와 매우 흡사한 방식이다. 심볼릭 링크가 참조하고 있는 파일과 심볼릭 링크 그 자체는 서로 구분하기 힘들 정도다. 예를 들면, 심볼릭 링크에 편집을 하게 되면 심볼릭 링크가 참조하고 있는 파일도 역시 똑같은 변경이 이루어진 다. 하지만 심볼릭 링크를 삭제하는 경우엔 그 링크만 삭제되고 파일은 남아있다. 심볼릭 링크를 삭 제하기 전에 파일을 지웠다면 심볼릭 링크는 살아있지만 이 링크는 아무것도 가리키지 않게 된다. 이 러한 경우를 링크가 깨졌다고 표현한다. 많은 쉘에서 ls 명령어로 인해 빨간색이나 다른 색상으로 깨진 링크를 볼 수 있다.
  • 17. Redirection 1. Redirecting Standard Input, Output, And Error- cat command 2. pipelines 3. Filters - uniq, wc, grep, cut, paste, join, head, tail, tee command In this lesson we are going to unleash what may be the coolest feature of the command line. It's called I/O redirection (입출력 방향지정). The “I/O” stands for input/output and with this facility you can redirect(재지정) the input and output of commands to and from files, as well as connect multiple commands together into powerful command pipelines.
  • 18. 1. Standard Input, Output, And Error programs such as ls actually send their results to a special file called standard output (often expressed as stdout) and their status messages to another file called standard error (stderr). By default, both standard output and standard error are linked to the screen and not saved into a disk file. In addition, many programs take input from a facility called standard input (stdin) which is, by default, attached to the keyboard.
  • 19. Redirecting Standard Output I/O redirection allows us to redefine where standard output goes. To redirect standard output to another file instead of the screen, we use the “>” redirection operator followed by the name of the file. $ ls -l /usr/bin > ls-output.txt $ ls -l ls-output.txt $ less ls-output.txt $ ls -l /bin/usr > ls-output.txt 오류메세지만을 만들기 때문에 크기가 0인 파일로 덮어씀 $ > ls-output.txt 위 원리를 이용하여 새로운 빈 파일을 만들거나 파일을 잘라냄 $ ls -l /usr/bin >> ls-output.txt 출력할 내용을 파일에 이어서 작성, 존재하지 않는 파일이 면 파일 생성
  • 20. Redirecting Standard Error Redirecting standard error lacks the ease of a dedicated redirection operator. To redirect standard error we must refer to its file descriptor. A program can produce output on any of several numbered file streams. While we have referred to the first three of these file streams as standard input, output and error, the shell references them internally as file descriptors 0, 1 and 2, respectively. The shell provides a notation for redirecting files using the file descriptor number. Since standard error is the same as file descriptor number 2, we can redirect standard error with this notation: $ ls -l /bin/usr 2> ls-error.txt The file descriptor “2” is placed immediately before the redirection operator to perform the redirection of standard error to the file ls-error.txt.
  • 21. Redirecting Standard Output And Standard Error To One File $ ls -l /bin/usr > ls-output.txt 2>&1 Using this method, we perform two redirections. First we redirect standard output to the file ls-output.txt and then we redirect file descriptor 2 (standard error) to file descriptor one (standard output) using the notation 2>&1. or $ ls -l /bin/usr &> ls-output.txt Disposing Of Unwanted Output This “/dev/null” file is a system device called a bit bucket which accepts input and does nothing with it. $ ls -l /bin/usr 2> /dev/null
  • 22. Redirecting Standard Input- cat command cat [file...]- Concatenate files and print on the standard output 파일과 표준 출력을 연결 하나이상의 파일을 읽어들여서 표준 출력으로 그 내용을 복사 주로 짧은 텍스트 파일을 표시할 때, 여러 파일을 하나로 합칠 때 $ cat ls-output.txt Say we have downloaded a large file that has been split into multiple parts (multimedia files are often split this way on Usenet), and we want to join them back together. If the files were named: movie.mpeg.001 movie.mpeg.002 ... movie.mpeg.099 we could join them back together with this command: $ cat movie.mpeg.0* > movie.mpeg $ cat > lazy_dog.txt The quick brown fox jumped over the lazy dog. 텍스트 입력 후 CTRL-D
  • 23. 2. Pipelines Using the pipe operator “|” (vertical bar), the standard output of one command can be piped into the standard input of another: command1 | command2 $ ls -l /usr/bin | less more, less – output the contents of file
  • 24. 3. Filters - uniq, grep, wc command Pipelines are often used to perform complex operations on data. It is possible to put several commands together into a pipeline. Frequently, the commands used this way are referred to as filters. Filters take input, change it somehow and then output it. sort - Sort lines of text uniq - Report or omit repeated lines $ ls /bin /usr/bin | sort | uniq | less 중복된 내용 삭제 $ ls /bin /usr/bin | sort | uniq -d | less 중복된 내용 표시 grep - Print lines matching a pattern (“-i” : 대소문자 구분안함, “-v” : 패턴과 일치하지않는 것 출력) $ ls /bin /usr/bin | sort | uniq | grep zip wc (word count) - Print newline, word, and byte counts for each file $ wc ls-output.txt 7902 64566 503634 ls-output.txt $ ls /bin /usr/bin | sort | uniq | wc –l 정렬된 목록에서 항목개수 ( -l :line 수만)
  • 25. 3. Filters – cut, paste, join command cut – Remove sections from each line of files paste – Merge lines of files join – Join lines of two files on a common field (참고) awk – 행 단위로 텍스트 파일을 편집
  • 26. 3. Filters - head, tail, tee command head - Output the first part of a file 앞 10줄 tail – Output the last part of a file 뒤 10줄 $ head -n 5 ls-output.txt 앞 5줄 tail -f file – output the contents of file as it grows, starting with the last 10 lines $ tail -f /var/log/messages 실시간으로 로그 파일 확인, CTRL-C 누를 때까지 계속 tee - Read from standard input and write to standard output and files 작업이 진행되고 있을 때 중간 지점의 파이프라인에 있는 내용을 알고 싶을 때 유용 $ ls /usr/bin | tee ls.txt | grep zip
  • 27. Expansion & Quoting 1. Expansion 2. Quoting
  • 28. 1. Expansion Each time you type a command line and press the enter key, bash performs several processes upon the text before it carries out your command. We have seen a couple of cases of how a simple character sequence, for example “*”, can have a lot of meaning to the shell. The process that makes this happen is called expansion. echo – Display a line of text $ echo this is a test this is a test Pathname Expansion 경로명 확장 (와일드카드로 동작하는 방식) $ echo * Desktop Documents ls-output.txt Music Pictures Public Templates Videos
  • 29. 1. Expansion Tilde(~) Expansion 틸드 확장 $ echo ~ 홈 디렉토리 /home/me Arithmetic Expansion 산술 확장 $ echo $((2 + 2)) 4 $ echo $(($((5**2)) * 3)) 75
  • 30. 1. Expansion Brace Expansion 중괄호 확장 $ echo Front-{A,B,C}-Back Front-A-Back Front-B-Back Front-C-Back $ echo {001..15} 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 Parameter Expansion 매개변수 확장 $ echo $USER 사용자명 표시 $ printenv | less 사용가능한 변수목록 보기 Command Substitution 명령어 치환 which – show which app will be run by default 실행프로그램의 위치 표시 $ ls -l $(which cp) or ls -l `which cp` 경로명 전체를 알지 못해도 cp 프로그램 내용볼수있다 -rwxr-xr-x 1 root root 71516 2007-12-05 08:58 /bin/cp $ file $(ls -d /usr/bin/* | grep zip)
  • 31. 2. Quoting Double Quotes 쉘에서 사용하는 특수한 기호들이 가진 의미가 없어지고 대신 일반적인 문자들로 인식 단, $,,’ 기호는 예외 즉 단어분할(공백삭제), 경로명 확장, 틸드 확장, 괄호 확장을 숨길 수 있지만 매개변수 확 장, 산술 확장, 명령어 치환은 그대로 시행 $ ls -l two words.txt ls: cannot access two: No such file or directory ls: cannot access words.txt: No such file or directory $ ls -l "two words.txt" -rw-rw-r-- 1 me me 18 2008-02-20 13:03 two words.txt
  • 32. 2. Quoting Single Quotes $ echo text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER text /home/me/ls-output.txt a b foo 4 me $ echo "text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER" text ~/*.txt {a,b} foo 4 me $ echo 'text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER' text ~/*.txt {a,b} $(echo foo) $((2+2)) $USER Escaping Characters (backslash) $ mv bad&filename good_filename
  • 33. Advanced Keyboard Tricks 1. Command line editing 2. Completion 3. Using history
  • 34. 1. Command Line Editing
  • 36. 3. Using History $ history | less By default, bash stores the last 500 commands you have entered. $ history | grep /usr/bin 88 ls -l /usr/bin > ls-output.txt The number “88” is the line number of the command in the history list. We could use this immediately using another type of expansion called history expansion. $ !88
  • 37. Permission $ ls -l foo.txt -rw-rw-r-- 1 me me 0 2008-03-06 14:52 foo.txt
  • 39. Permission id – Display user identity chmod – Change a file's mode 파일소유자나 슈퍼유저만이 가능 (1) 8진법 $ chmod 600 foo.txt $ ls -l foo.txt -rw------- 1 me me 0 2008-03-06 14:52 foo.txt chmod 777 – read, write, execute for all chmod 755 – rwx for owner, rx for group and world 4 – read (r) 2 – write (w) 1 – execute (x)
  • 41. Permission umask – Set the default file permissions su – Run a shell as another user sudo – Execute a command as another user chown – Change a file's owner passwd - Changing a password
  • 42. Permission sudo command How do you use sudo !!? Simply. Imagine you have entered the following command: $apt-get install ranger The words "Permission denied" will appear unless you are logged in with elevated privileges. This elevates privileges to the root-user administrative level temporarily, which is necessary when working with directories or files not owned by your user account. sudo !! runs the previous command as sudo. So the previous command now becomes: $sudo apt-get install ranger Logging in as another user (Please don't use this to become root) $sudo -i -u <username> Enabling the root account $sudo -i To enable the root account (i.e. set a password) use: $sudo passwd root Enabling the root account is rarely necessary. Almost everything you need to do as administrator of an Ubuntu system can be done via sudo or gksudo. If you really need a persistent root login, the best alternative is to simulate a root login shell using the following command...
  • 43. Process ps – display your currently active processes TTY(teletype) : the controlling terminal for the process
  • 44. Process top ('table of processes') – display all running processes jobs – List active jobs bg – lists stopped or background jobs; resume a stopped job in the background fg – brings the most recent job to foreground fg n – brings job n to the foreground kill – Send a signal to a process $ kill 28401 프로세스 종료 [1]+ Terminated xlogo 작업번호1인 xlogo 프로그램을 종료함 killall – Kill processes by name shutdown – Shutdown or reboot the system
  • 45. Part 2 – Configuration And The Environment
  • 46. The Environment What Is Stored In The Environment? The shell stores two basic types of data in the environment, though, with bash, the types are largely indistinguishable. They are environment variables and shell variables. Shell variables are bits of data placed there by bash, and environment variables are basically everything else. In addition to variables, the shell variables also stores some programmatic data, namely aliases and shell functions.
  • 47. The Environment alias – Create an alias for a command $ alias alias l.='ls -d .* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias –showdot --show-tilde'
  • 48. The Environment How Is The Environment Established? What's A Startup File And What’s In That? When we log on to the system, the bash program starts, and reads a series of configuration scripts called startup files, which define the default environment shared by all users. If the file "~/.bashrc" exists, then read the "~/.bashrc" file.
  • 49. The Environment Modifying The Environment $ cp .bashrc .bashrc.bak 만약을 위해 백업파일 만듬 $ nano .bashrc nano 편집기로 다음 내용을 추가 # Change umask to make directory sharing easier umask 0002 # Ignore duplicates in command history and increase # history size to 1000 lines export HISTCONTROL=ignoredups export HISTSIZE=1000 # Add some helpful aliases alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto‘ Ctrl-o : save, Ctrl-x : exit nano $ source .bashrc 변경사항 적용 =. .bashrc
  • 51. VIM editor * 입력 명령어 i 현재 커서 위치에 삽입(왼쪽) a 현재 커서 위치 다음에 삽입 o 현재 커서가 위치한 줄의 아랫줄에 삽입 O 현재 커서가 위치한 줄의 바로 위에 삽입 I 현재 커서가 위치한 줄의맨 앞에 삽입 A 현재 커서가 위치한 줄의 맨 뒤에 삽입 * 지우기 명령어 x 현재 커서 위치의 문자를 삭제 dd 현재 커서가 위치한 줄을 삭제 dw 현재 커서가 위치한 단어를 삭제 d$ 현재 커서가 위치한 곳부터 그 행의 끝까지 삭제 dG 현재 커서가 위치한 행부터 편집문서의 마지막 줄까지 삭제 *. 삭제한 내용은 바로 지워지지 않고 버퍼에 저장되므로 붙여넣기 하거나 취소 할 수 있다. * 복사하기와 붙이기 yy(=Y) 현재 커서가 위치한 줄을 버퍼에 복사(nyy => 현재 커서가 위치한 곳부터 아래로 n 라인을 버퍼에 복사한다) yw 현재 커서가 위치한 단어를 버퍼에 복사(nyw => 현재 커서가 위치한 단어부터 오른쪽으로 n개의 단어를 버퍼에 복사한다) p 버퍼에 들어 있는 내용을 현재 커서가 위치한 줄의 아래에 붙이기 P 버퍼에 들어 있는 내용을 현재 커서가 위치한 줄의 위에 붙이기 * 치환 r 현재 위치의 문자를 한개만 바꾼다. R 현재 커서위치에서 오른쪽으로 esc 키를 입력할 때 까지 바꾼다. cw 현재 위치의 단어를 바꾼다. cc 현재 커서가 위치한 줄을 바꾼다. C 현재 커서가 위치한 곳으로부터 줄의 끝까지 바꾼다. ~ 대소문자를 서로 바꾼다. * 취소 명령어 u 방금 한 명령을 취소한다. U 현재 커서가 위치한 줄에 대한 편집 명령을 취소한다. ^R (=redo) 취소한 명령을 다시 취소 (vim) . 방금한 명령을 되풀이 한다.
  • 52. VIM editor * 이동 명령어 정리 ^b(back) 한 화면 위로 이동 ^u(up) 반 화면 위로 이동 ^f(forward) 한 화면 아래로 이동 ^d(down) 반 화면 아래로 이동 e 한 단어 뒤로 이동 b 한 단어 앞으로 이동 0 줄의 제일 처음부터 이동 $ 줄의 제일 끝으로 이동
  • 53. VIM editor 스크립트 작성을 용이하게 해주는 옵션 :syntax on 구문 강조 기능. 쉘 구문마다 다른 색상으로 표시해주기 때문에 프로그래밍 오류 를 쉽게 찾아낼 수 있다. vim editor의 풀버전이 설치되어 있어야 한다. :set hlsearch 검색 결과를 강조하여 표시. :set autoindent 자동 들여쓰기 기능. 사용하지 않으려면 CTRL-D 이 옵션들을 영구적으로 적용하려면 ~/.vimrc 파일에 이 옵션을 추가(콜론기호는 제외하고 입력)
  • 54. Part 3 – Common Tasks And Essential Tools
  • 55. Networking Network ping host – ping host and output results 네트워크 호스트로 고유 패킷(IMCP ECHO-REQUEST) 전송 whois domain – get whois information for domain dig domain – get DNS information for domain dig -x host – reverse lookup host wget file – download file $wget http://sourceforge.net/projects/antix-linux/files/Final/MX-krete/antiX-15-V_386-full.iso/download wget -c file – continue a stopped download SSH(Secure Shell) ssh user@host – connect to host as user 원격호스트와 안전하게 통신 ssh -p port user@host – connect to host on port as user ssh-copy-id user@host – add your key to host for user to enable a keyed or passwordless login
  • 56. Searching locate – Find files by name 파일명으로 파일 찾기 $ locate bin/zip zip으로 시작하는 프로그램(명령어)찾기 $ locate zip | grep bin zip 문자열이 포함된 프로그램 찾기 find – Search for files in a directory hierarchy 주어진 디렉토리 트리내에서 특정조건에 부합하는 파일 검색하기 $ find ~ -type d | wc –l -type d:검색결과에서 디렉토리 목록만 보기
  • 57. Searching $ find ~ ( -type f -not -perm 0600 ) -or ( -type d -not -perm 0700 ) 파일들의 퍼미션이 0600으로 설정되어 있지 않거나 디렉토리의 퍼미션이 0700으로 설정되어 있지 않은지 확인 $ find ~ -type f -name '*.BAK' –delete 백업파일 확장자를 가진 파일을 삭제
  • 58. Archiving And Backup Compressing Files 파일 압축하기 gzip file – compresses file and renames it to file.gz gzip -d file.gz – decompresses file.gz back to file bzip2 file – 속도는 느리지만 고성능 압축 zip –r file.zip file – zip파일로 압축. 윈도우 시스템과 파일을 교환할때 (-r: 하위디렉토리 포함) Archiving Files 파일 보관하기(많은 파일들을 모아서 하나의 큰 파일로 묶는 과정) tar cf file.tar files – create a tar(tape archive) named file.tar containing files tar xf file.tar – extract the files from file.tar 아카이브 해제 tar czf file.tar.gz files – create a tar with Gzip compression tar xzf file.tar.gz – extract a tar using Gzip tar cjf file.tar.bz2 – create a tar with Bzip2 compression tar xjf file.tar.bz2 – extract a tar using Bzip2 f : 아카이브의 이름을 지정
  • 59. Regular Expressions Simply put, regular expressions are symbolic notations used to identify patterns in text. In some ways, they resemble the shell’s wildcard method of matching file and pathnames, but on a much grander scale. http://coffeenix.net/doc/regexp/node17.html [^bg] 괄호표현식 안의 ^는 부정의 의미, ^[A-Z] 괄호표현식안의 –는 문자범위
  • 60. Regular Expressions http://regexr.com/ 정규 표현식에 대한 도움말과 각종 사례들을 보여주는 서비스로 정규표현식을 라이브로 만들 수 있는 기능도 제공하고 있다.
  • 63. Compiling Programs Simply put, compiling is the process of translating source code (the human-readable description of a program written by a programmer) into the native language of the computer’s processor. The computer’s processor (or CPU) works at a very elemental level, executing programs in what is called machine language. This is a numeric code that describes very small operations, such as “add this byte,” “point to this location in memory,” or “copy this byte.” Each of these instructions is expressed in binary (ones and zeros). This problem was overcome by the advent of assembly language, which replaced the numeric codes with (slightly) easier to use character mnemonics such as CPY (for copy) and MOV (for move). Programs written in assembly language are processed into machine language by a program called an assembler. Assembly language is still used today for certain specialized programming tasks, such as device drivers and embedded systems.
  • 64. Compiling Programs We next come to what are called high-level programming languages. They are called this because they allow the programmer to be less concerned with the details of what the processor is doing and more with solving the problem at hand. While there are many popular programming languages, two predominate. Most programs written for modern systems are written in either C or C++. In the examples to follow, we will be compiling a C program. Programs written in high-level programming languages are converted into machine language by processing them with another program, called a compiler. Some compilers translate high-level instructions into assembly language and then use an assembler to perform the final stage of translation into machine language. A process often used in conjunction with compiling is called linking. There are many common tasks performed by programs. Take, for instance, opening a file. Many programs perform this task, but it would be wasteful to have each program implement its own routine to open files. It makes more sense to have a single piece of programming that knows how to open files and to allow all programs that need it to share it. Providing support for common tasks is accomplished by what are called libraries. They contain multiple routines, each performing some common task that multiple programs can share. If we look in the /lib and /usr/lib directories, we can see where many of them live. A program called a linker is used to form the connections between the output of the compiler and the libraries that the compiled program requires. The final result of this process is the executable program file, ready for use.
  • 65. Compiling Programs There are programs such as shell scripts that do not require compiling. They are executed directly. These are written in what are known as scripting or interpreted languages. These languages have grown in popularity in recent years and include Perl, Python, PHP, Ruby, and many others. Scripted languages are executed by a special program called an interpreter. An interpreter inputs the program file and reads and executes each instruction contained within it. In general, interpreted programs execute much more slowly than compiled programs. This is because that each source code instruction in an interpreted program is translated every time it is carried out, whereas with a compiled program, a source code instruction is only translated once, and this translation is permanently recorded in the final executable file.
  • 66. Compiling Programs Install from source: ./configure make make install make – Utility to maintain programs
  • 67. Part 4 – Writing Shell Scripts
  • 68. Writing Shell Script In the simplest terms, a shell script is a file containing a series of commands. The shell reads this file and carries out the commands as though they have been entered directly on the command line. The shell is somewhat unique, in that it is both a powerful command line interface to the system and a scripting language interpreter.
  • 69. Writing Shell Script How To Write A Shell Script To successfully create and run a shell script, we need to do three things: 1. Write a script. Shell scripts are ordinary text files. So we need a text editor to write them. The best text editors will provide syntax highlighting, allowing us to see a color-coded view of the elements of the script. Syntax highlighting will help us spot certain kinds of common errors. vim, gedit, kate, and many other editors are good candidates for writing scripts. 2. Make the script executable. The system is rather fussy about not letting any old text file be treated as a program, and for good reason! We need to set the script file’s permissions to allow execution. 3. Put the script somewhere the shell can find it. The shell automatically searches certain directories for executable files when no explicit pathname is specified. For maximum convenience, we will place our scripts in these directories.
  • 70. Writing Shell Script 1. Write a script. #!/bin/bash # This is our first script. echo 'Hello World!' 2. Make the script executable. $ ls -l hello_world -rw-r--r-- 1 me me 63 2009-03-07 10:10 hello_world $ chmod 755 hello_world $ ls -l hello_world -rwxr-xr-x 1 me me 63 2009-03-07 10:10 hello_world 3. Put the script somewhere the shell can find it. In order for the script to run, we must precede the script name with an explicit path. $ ./hello_world $ mkdir bin ~/bin 디렉토리는 개인적인 용도로 사용하려는 스크립트를 저장하기에 적합한 장소 $ mv hello_world bin $ hello_world Hello World! #!(shebang) 뒤따라오는 스크립트를 실행하기 위한 인터프리 터의 이름을 시스템에 알려준다. 모든 쉘 스크립트 첫줄에 반드시 존재해야 한다.
  • 71. Part 5 – etc..
  • 72. Shortcuts Ctrl+C – halts the current command Ctrl+Z – stops the current command, resume with fg in the foreground or bg in the background Ctrl+D – log out of current session, similar to exit Ctrl+W – erases one word in the current line Ctrl+U – erases the whole line Ctrl+R – type to bring up a recent command !! - repeats the last command exit – log out of current session Ctrl+K - Cuts text from the cursor until the end of the line Ctrl+Y - Pastes text Ctrl+E or End - Move cursor to end of line Ctrl+A or Home - Move cursor to the beginning of the line ALT+F - Jump forward to next space ALT+B - Skip back to previous space ALT+Backspace - Delete previous word Ctrl+W - Cut word behind cursor Shift+Insert - Pastes text into terminal
  • 73. Happy New Year ! Get Your Fortune Told Another one that isn't particularly useful but just a bit of fun is the fortune command. Like the sl command you might need to install it from your repository first. sudo apt-get install fortune-mod Then simply type the following to get your fortune told fortune Get A Cow To Tell Your Fortune Finally get a cow to tell you your fortune using cowsay. Type the following into your terminal: fortune | cowsay If you have a graphical desktop you can use xcowsay to get a cartoon cow to show your fortune: fortune | xcowsay cowsay and xcowsay can be used to display any message. For example to display "Hello World" simply use the following command: cowsay "hello world" http://linux.about.com/od/commands/tp/11-Linux-Terminal-Commands-That-Will-Rock-Your-World.01.htm https://www.digitalocean.com/community/tutorials/top-10-linux-easter-eggs