레이블이 command인 게시물을 표시합니다. 모든 게시물 표시
레이블이 command인 게시물을 표시합니다. 모든 게시물 표시

4/12/2020

기초 리눅스 명령어

** 기초 리눅스 명령어


- pwd : Present Working Directory. Print Working Directory.


- cd : To change to a particular directory.

- cd .. : Move one directory level up.

- cd directory1/directory2 : Navigating through multiple directories.

- cd / : Move to the root directory.

- cd or cd ~ : Navigate to HOME directory. To return to home directory.


- ls : Lists all files and directories in the present working directory.

- ls -R : Lists files in sub-directories as well.

- ls -a : Lists hidden files as well. Hidden files start with '.' period symbol.

- ls -al : Lists files and directories with detailed information.


- cat : Display, Copy, Combine, Create text files.

- cat > filename : Creates a new file.

- cat filename : Displays the file content.

- cat file1 file2 > file3 : Joins two files(file1, file2) and stores the output in a new file(file3).


- mv file "new file path" : Moves the files to the new location.

- mv filename new_file_name : Renames the file to a new filename.


- sudo : Allows regular users to run programs as superuser or root.


- rm : Deletes a file.


- mkdir : Creates a new directory in the present working directory.

- mkdir : Create a new directory at the specified path.


- rmdir : Deletes a directory.


- mv : Renames a directory.


- man : Gives help information on a command.


- history : Gives a list of all past commands typed in the current terminal session.


- clear : Clears the terminal.

---------------------------------------------------------------------

`` pr Command : Printing on Linux


` Pr Command Options

- pr -x : Divides the data into 'x' columns

- pr -h "header" : Assigns "header" value as the report header

- pr -t : Does not print the header and top/bottom margins

- pr -d : Double spaces the output file

- pr -n : Denotes all line with numbers

- pr -l page length : Defines the lines (page length) in a page. Default is 56

- pr -o margin : Formats the page in accordance with the margin number



`` lp Filename or lpr Filename : Hard Copy

- Printing 'N' copies of file

- lp -nN Filename or lpr n Filename

- lp -dPrintername Filename or lpr -PPrintername Filename : Choosing Printers


---------------------------------------------------------------------


`` apt-get : Command used to install and update packages


- sudo apt-get install Softwarename : Installing Software


---------------------------------------------------------------------



`` Mailx address body : Command to send email

`` email address body : Command to send email



---------------------------------------------------------------------


`` Redirection in Linux

` Input / Output

- Standard Input (stdin) device is the keyboard.

- Standard Output (stdout) device is the Screen.


` Output Redirection

- The '>' symbol is used for output (stdout) redirection.

- Output Redirection >

- ">" is the output redirection operator. ">>" appends output to an existing file.


` Input redirection

- The '<' symbol is used for input (stdin) redirection.

- < Input Redirection

- ex) mail -s "News Today" abc@mail.com < NewsFlash


` Error Redirection

- Standard Input STDIN : FD0

- Standard Output STDOUT : FD1

- Standard Error STDERR : FD2



` Why Error Redirection?

- Searching for files typically gets permission denied errors.

- Error messages clutter up program output while executing shell scripts.

- Solution = Redirect error messages


` ls Documents ABC > dirlist 2>&1

- ">&" which writes the output from one file to the input of another file.

- Error output is redirected to standard output which in turn is being re-directed to file dirlist.

- ">&" re-directs output of one file to another.


---------------------------------------------------------------------


`` Pipes


- The symbol '|' denotes a pipe.

- Use Pipes to run two commands consecutively.

- Helps in creating powerful commands

ex) cat aaa.txt | less


` 'pg' and 'more' commands

- cat Filename | pg

- cat Filename | more



`` grep 

- Scan a document

- Present the result in a format you want

- grep

ex) cat aaa.txt | grep han



` The 'grep' command

- -v : Shows all the lines that do not match the searched string.

- -c : Displays only the count of matching lines.

- -n : Shows the matching line and its number.

- -i : Match both (upper and lower) case, all lines that match the character.

- -l : Shows just the name of the file with the string.



`` The 'sort' command

- Sorting the contents of a file

- sort Filename


` The 'sort' Option

- -r : Reverses sorting

- -n : Sorts numerically

- -f : Case insensitive sorting


` Pipes '|' help combine 2 or more commands.

` A filter in a pipe is an output of one command which serves as input to the next.

` The grep command can be used to find strings and values in a text document.

` 'sort' command sorts out the content of a file alphabetically.

` less, pg and more commands are used for dividing a long file into readable bits.


---------------------------------------------------------------------


`` Regular Expressions


` tr, sed, vi, grep

- . : replaces any character

- ^ : matches start of string

- $ : matches end of string

- * : matches up zero or more times the preceding character

- : Represent special characters

- () : Groups regular expressions

- ? : Matches up exactly one character


` Interval Regular Expressions

- Number of occurrences of a character in a string.

- {n} : Matches the preceding character appearing 'n' times exactly

- {n,m} : Matches the preceding character appearing 'n' times but not more than m

- {n,} : Matches the preceding character only when it appears 'n' times or more


` Extended regular Expressions

- \+ : Matches one or more occurrence of the previous character

- \? : Matches zero or one occurrence of the previous character


` Brace Expansion

- Sequence : {0..10}, {a..z}

- Comma Separated List : {aa, bb, cc, dd}


` Summary

- Regular expressions are a set of characters used to check patterns in strings.

- They are also called 'regexp' and 'regex'.

- It is important to learn regular expressions for writing scripts.


` Some basic regular expressions are:

- . : replaces any character

- ^ : matches start of string

- $ : matches end of string


` Some extended regular expressions are :

- \+ : Matches one or more occurrence of the previous character

- \? : Matches zero or one occurrence of the previous character


` Some interval regular expressions are :

- {n} : Matches the preceding character appearing 'n' times exactly

- {n,m} : Matches the preceding character appearing 'n' times but not more than m

- {n, } : Matches the preceding character only when it appears 'n' times or more

- The brace expansion is used to generate strings. It helps in creating multiple strings out of one.

---------------------------------------------------------------------

`` Managing Processes


` Process?

- An instance of a program is called a Process.

- Any command that you give to your Linux machine starts a new process.


` Types of Processes

- Foreground Processes

- Background Processes


` Background Process

1. Start the program

2. Press Ctrl + Z

3. Type bg to send process to background


` FG Command

- fg (jobname)



` Top

- Displays all the running processes.

- top

` process Status

- D : Uninterruptible sleep

- R : Running

- S : Sleeping

- T : Traced or Stopped

- Z : Zombie



` PS

- Process Status

- ps ux

- ps PID



` kill

- Terminates running processes

- kill PID

- niceness : -20 to 19 : Lower the niceness index, higher would be the priority


` NICE

- Default value of all the processes is 0

- nice -n 'Nice value' process name

- renice 'nice value' -p 'PID'


` DF

- Reports the free disk space

- df


` FREE

- Shows free and used memory (RAM) on the Linux system

- free -m

- free -g


`` Summary

- Any running program or a command given to a Linux system is called a process.

- A process could run in foreground or background.

- The priority index of a process is called Nice in Linux. Its default value is 0 and it can vary between 20 to -19.

- The lower the Niceness index the higher would be priority given to that task.

- bg : To send a process to background

- fg : To run a stopped process in foreground

- top : Details on all Active Processes

- ps : Give the status of processes running for a user

- ps PID : Gives the status of a particular process

- pidof : Gives the Process ID(PID) of a process

- kill PID : kills a process

- nice : Starts a process with a given priority

- renice : Changes priority of an already running process

- df : Gives free hard disk space on your system

- free : Tells the free RAM on your system


---------------------------------------------------------------------


12/28/2006

[winxp] WindowsXP 콘솔 명령어

- Attrib : 파일 및 디렉토리의 속성 변경.

- Batch : inputfile 명령어 실행. 명령 결과 저장시 outputfile 옵션 사용.

- Bootcfg : "boot.ini" 파일 편집.

- CD(Chdir) : 현재 디렉토리의 이름을 표시하거나 다른 디렉토리로 전환.

- Chkdsk : 디스크 무결성 검사 및 결과 출력.

- Cls : 스크린 클리어.

- Copy : 파일 복사. 기본 설정 값에서는 와일드 카드 사용할 수 없음.

- Del(Delete) : 파일 삭제. 기본 설정 값에서는 와일드 카드 사용할 수 없음.

- Dir : 파일이나 디렉토리 목록 표시. 화면, 프린터, 파일로 출력 가능.

- Disable : 서비스나 드라이버 중지.

- Diskpart : 파티션 생성, 제거 등의 파티션 설정 작업 수행.

- Enable : 서비스나 드라이버 시작.

- Exit : 콘솔 종료.

- Expand : 설치 CD에 있는 압축된 파일 해제.

- Fixboot : 부트 파티션에 부트 섹터 생성.

- Fixmbr : 부트 파티션에 마스터 부트 레코드(MBR) 생성.

- Format : 드라이브를 FAT32 or NTFS 형식으로 포맷.

- Help : 각 명령어에 대한 자세한 설명 출력.

- Listsvc : 서비스와 드라이버 항목을 화면에 표시.

- Logon : 윈도우 설치 목록을 표시하고 해당 설치 항목에 로그온.

- Map : 현재 연결되어 있는 모든 장치의 현재 상태 출력.

- MD(Mkdir) : 디렉토리 생성.

- More/Type : 지정한 파일을 화면에 출력.

- Net Use : 원격 공유 연결 실행.

- Rd(Rmdir) : 디렉토리 삭제.

- Ren(Rename) : 파일이나 디렉토리의 이름을 바꿈.

- Set : 콘솔 환경 설정 상태 표시.

- Systemroot : 현재 디렉토리를 %SystemRoot%로 설정.