블로그 이미지
:: OTL ≠ 좌절 :: OTL = 운(運) ::
coriahn

Notice

Archive

  • 19,286total
  • 12today
  • 58yesterday
2011/01/28 17:40 3-1. Linux/::Command::
tail -10 /var/log/message | mail -s "log message" coriahn@otl.ne.kr

저작자 표시
posted by coriahn
2011/01/28 15:12 3-1. Linux/::Command::
오늘 날짜
[root@lin ~]# date +'%Y%m%d'
20110128

어제 날짜
[root@lin ~]# date -d '1 day ago' +'%Y%m%d'
20110127

이틀전
[root@lin ~]# date -d '2 day ago' +'%Y%m%d'
20110126

한달 이틀전
[root@lin ~]# date -d '1 month ago 2 day ago' +'%Y%m%d'
20101226

그렇다면 내일 날짜는 어떻게 알수 있을까????

오늘 날짜
[root@lin2 tmp]# date +'%Y%m%d'
20110211

내일 날짜
[root@lin2 tmp]# date -d '1 day' +'%Y%m%d'
20110212

모레 날짜
[root@lin2 tmp]# date -d '2 day' +'%Y%m%d'
20110213

한달 2일후 날짜
[root@lin2 tmp]# date -d '1 month 2 day' +'%Y%m%d'
20110313

2년 1개월 2일후 날짜
[root@lin2 tmp]# date -d '2 year 1 month 2 day' +'%Y%m%d'
20130313
저작자 표시
posted by coriahn
2011/01/28 10:43 3-1. Linux/::Command::

1.     패턴으로 문자열 자르기

1.1. 패턴에서 6번째  추출(/etc/passwd에서  디렉토리 추출)

# grep coriahn /etc/passwd | awk -F : '{print $6}'

Awk 이용해서 : 구분자로 6번째 필드를 출력


1.2. 패턴에서 마지막  추출(패스에서 마지막 패스 추출)

# echo ${PATH##*:}

: 구분자로 마지막값 출력 ## 의미는 일단 미지수


1.3. 패턴에서 마지막  잘라내기(파일명에서 확장자 제거)

# path=back.sh

# echo ${path%.*}

back

“.”을 구분자로 하여 마지막 패턴을 삭제하는듯


2.     추가사항은 나중에..

 

BASH: Split a string without ‘cut’ or ‘awk’

For a little test script I’m writing I needed to split a line on a ‘;’ but preservere the “s and ‘s, something that echo doesn’t like to do. Digging deeper into the bash docs I see that there are some handy string handling functions.

#!/bin/bash
line=’this “is” a command;this “is” a pattern’
COMMAND=${line%;*}
PATTERN=${line#*;}
echo $COMMAND
echo $PATTERN

And the output would be:

this “is” a command
this “is” a pattern


http://www.antonolsen.com/2006/04/10/bash-split-a-string-without-cut-or-awk/


저작자 표시
posted by coriahn
2011/01/04 14:39 3-1. Linux/::Command::
yum 기능 중 groupinstall이라는 옵션이 있다.

이 기능을 이용하면 미리 설정된 패키지들을 손쉽게 설치할 수 있도록 해준다.

1. 그룹 목록 확인

[root@localhost ~]# yum grouplist
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
 * addons: data.nicehosting.co.kr
 * base: data.nicehosting.co.kr
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
Installed Groups:
   Administration Tools
   DNS Name Server
   Dialup Networking Support
   Editors
   FTP Server
   GNOME Desktop Environment
   Games and Entertainment
   Graphical Internet
   Graphics
   Java
   Legacy Network Server
   Mail Server
   MySQL Database
   Network Servers
   News Server
   Office/Productivity
   Printing Support
   Server Configuration Tools
   Sound and Video
   System Tools
   Text-based Internet
   Web Server
   Windows File Server
   X Window System
   Yum Utilities
Available Groups:
   Authoring and Publishing
   Base
   Beagle
   Cluster Storage
   Clustering
   Development Libraries
   Development Tools
   Emacs
   Engineering and Scientific
   FreeNX and NX
   GNOME Software Development
   Horde
   Java Development
   KDE (K Desktop Environment)
   KDE Software Development
   KVM
   Legacy Software Development
   Legacy Software Support
   Mono
   OpenFabrics Enterprise Distribution
   PostgreSQL Database
   Ruby
   Tomboy
   Virtualization
   X Software Development
   XFCE-4.4
Done

2. 그룹 설치하기
yum groupinstall -y "Cluster Storage" "Clustering"
위의 명령은 Cluster Storage 그룹과 Clustering 그룹을 설치 여부 질문 없이 설치하도록 한다.

2.1 또 다른 방법
# yum install @cluster-storage @clustering
위 명령은 동일한 명령을 수행한다. 

저작자 표시
posted by coriahn
2010/02/25 14:10 3-1. Linux/::Command::
# free -m -t


total
used free shared buffers cached
Mem: 2022 1420 602 0
64
1137
-/+ buffers/cache: 218 1804



Swap: 1983 0
1983


Total:
4006 1420 2586




mem의 total : 물리적 메모리의 값(2G)
           used : 물리적 메모리의 사용량
           free : 물리적 메모리의 남은량
           shared : ??
           buffers : 버퍼영역으로 할당된 메모리
           cached : 케시영역으로 할당된 메모리

-/+ buffers/cache의 used : 버퍼와 케시영역을 제외한 실질적인 사용량
                             free : 버퍼와 케시영역을 포함한 실질적인 메모리의 남은량(mem의 free, buffers, cached 의 값을 더한값)
저작자 표시
posted by coriahn
2009/12/02 16:07 3-1. Linux/::Command::
ftp://ftp.kernel.org/pub/linux/utils/util-linux/
여기서 파일 받은 다음에 압축풀고..
find로 write 검색 해보세요..

write.c라는 파일이 있네요..
저작자 표시
posted by coriahn
2009/09/09 10:24 3-1. Linux/::Command::
리눅스에서는 CD이미지(ISO)를 마운트 하기위해 별도의 프로그램을 필요로 하지 않습니다.
참 좋은 현상이죠...

# mount -o loop -t iso9660 -r /home/test.iso /mnt/iso
깔끔하게 명령어 한줄로 마운트 시키기.. 굿입니다 아주 굿이에요..
저작자 표시
posted by coriahn
2009/08/13 10:31 3-1. Linux/::Command::
PC의 메인 운영체제를 리눅스로 변경하면서..
영화를 보다가 잘때 꼭 유용한 명령어다.. ㅋㅋㅋㅋ


- shutdown을 이용한 시스템 종료 및 재시작
# /sbin/shutdown [-t sec] [-rkhncfF] time [warning-messages]
  -k : 실제로 종료하지 않고 모든 사용자에게 경고 메시지만을 보냅니다.
  -r : 시스템 종료후에 재부팅을 합니다.(reboot)
  -h : 시스템을 종료하며 재부팅을 하지 않습니다.(halt)
  -f : 재부팅할 때 파일시스템체ㅡ를 (fsck: file system check)를 하지 않습니다.
  -c : 이전에 내렸던 shutdown명령을 취소합니다.
  time : 몇분 후에 시스템을 종료할 것인가를 지정합니다.
  warning-messages : 사용자에게 보내질 종료 메시지.

# shutdown -h 5 "system rebooting..." -> "system rebooting..." 메시를 뿌리면서 현재부터 5분 후에 시스템을 종료
# shutdown -c -> shutdown 종료명령 취소
# shutdown -r +5 "system rebooting..." -> 5분 후에 시스템을 재시작
# shutdown -r now -> 시스템을 즉시 재부팅
# shutdown -h now -> 시스템을 즉시 종료
- reboot(= shutdown -r now)으로 서버 재시작하기
- poweroff로 서버 종료하기
- halt(= shutdown -h now)로 서버 종료하기
- init을 원하는 실행레벨로 서버 종료 및 재시작

펌'd by 민군넷
posted by coriahn
2009/03/30 19:25 3-1. Linux/::Command::

xxd 명령어는 리눅스 shell상에서 binary파일(이진파일)의 hexdump를 보여주는 명령어이다.

기본 사용법은


xxd [option] filename

과 같다.

 

버전에 따라 약간의 차이는 있지만 option 동작은 다음과 같다.





-b : dump가 이진법(즉, 0과1)로 출력됨.

-c 갯수 : 행(line)당 출력되는 열(column)의 갯수 설정.

-g 갯수 : 출력시 group으로 묶이는 byte의 갯수를 설정.

-l 길이 : 설정된 길이 byte 만큼만 출력됨

-p 또는 -ps : 주소나 ASCII없이 hexdump 내용만 출력됨.

-u : hex를 소문자 대신 대문자로 출력.

-s [+][-]위치 : 설정된 위치에서 부터 hexdump함. 위치 또는 +위치는 파일의 시작부터의 위치를 나타내고, -위치는 파일의 끝에서 부터의 위치를 나타냄.

-i : C언어에서 사용할수 있는 형식으로 출력.

-r : 반대로 hexdump를 binary 파일로 바꾸어 준다.

posted by coriahn
2009/03/23 11:14 3-1. Linux/::Command::

rename 's/.txt$/.doc/' *


NAME
       rename - renames multiple files

SYNOPSIS
       rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

DESCRIPTION
       "rename" renames the filenames supplied according to the rule specified as the first
       argument.  The perlexpr argument is a Perl expression which is expected to modify the
       $_ string in Perl for at least some of the filenames specified.  If a given filename
       is not modified by the expression, it will not be renamed.  If no filenames are given
       on the command line, filenames will be read via standard input.

       For example, to rename all files matching "*.bak" to strip the extension, you might
       say

               rename 's/\.bak$//' *.bak

       To translate uppercase names to lower, you'd use

               rename 'y/A-Z/a-z/' *

OPTIONS
       -v, --verbose
               Verbose: print names of files successfully renamed.

       -n, --no-act
               No Action: show what files would have been renamed.

       -f, --force
               Force: overwrite existing files.

ENVIRONMENT
       No environment variables are used.

AUTHOR
       Larry Wall

SEE ALSO
posted by coriahn