'2017/01/19'에 해당되는 글 4건

  1. 2017.01.19 [Ubuntu] hostname 변경
  2. 2017.01.19 [Ubuntu] Word Count
  3. 2017.01.19 [Ubuntu] Memory 확인
  4. 2017.01.19 [Ubuntu] Filesystem 용량 확인

[Ubuntu] hostname 변경

OS/Linux 2017. 1. 19. 16:00

Ubuntu에서 현재 컴퓨터의 이름인 hostname 을 변경하는 법에 대해 알아보자.


현재 hostname은 shell 에서 $ hostname 명령을 통하여 알 수 있다.


hostname을 수정하려면 다음 2개의 파일을 원하는 이름으로 수정하고 재부팅하면 hostname이 수정되어 반영된다. 

  • sudo vi /etc/hostname
  • sudo vi /etc/hosts

$ hostname

leechwin-linux $ cat /etc/hostname leechwin-linux $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 leechwin-linux # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters



'OS > Linux' 카테고리의 다른 글

[Ubuntu] ln 명령으로 링크 만들기  (0) 2019.02.27
[Ubuntu] sudo 권한 등록  (0) 2017.08.09
[Ubuntu] Word Count  (0) 2017.01.19
[Ubuntu] Memory 확인  (0) 2017.01.19
[Ubuntu] Filesystem 용량 확인  (0) 2017.01.19
Posted by leechwin
,

[Ubuntu] Word Count

OS/Linux 2017. 1. 19. 15:47

Ubuntu 환경의 쉘에서 특정 word를 count하거나 특정 파일의 라인수를 카운트하는 wc 명령에 대해 알아보자.


$ wc --help

Usage: wc [OPTION]... [FILE]... or: wc [OPTION]... --files0-from=F Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. A word is a non-zero-length sequence of characters delimited by white space. With no FILE, or when FILE is -, read standard input. The options below may be used to select which counts are printed, always in the following order: newline, word, character, byte, maximum line length. -c, --bytes print the byte counts -m, --chars print the character counts -l, --lines print the newline counts --files0-from=F read input from the files specified by NUL-terminated names in file F; If F is - then read names from standard input -L, --max-line-length print the maximum display width -w, --words print the word counts --help display this help and exit --version output version information and exit GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Full documentation at: <http://www.gnu.org/software/coreutils/wc> or available locally via: info '(coreutils) wc invocation'

wc 명령은 다음과 같이 여러가지로 이용가능하다.
  • 특정 파일의 라인수 카운트

$ wc -l test.md

42 test.md
  • 특정 문자 카운트

    $ cat test.md | grep config | wc -l

    4 $ cat /proc/cpuinfo | grep processor | wc -l 8


    'OS > Linux' 카테고리의 다른 글

    [Ubuntu] sudo 권한 등록  (0) 2017.08.09
    [Ubuntu] hostname 변경  (0) 2017.01.19
    [Ubuntu] Memory 확인  (0) 2017.01.19
    [Ubuntu] Filesystem 용량 확인  (0) 2017.01.19
    [Ubuntu] 커널버전 및 Ubuntu 버전 확인  (0) 2017.01.18
    Posted by leechwin
    ,

    [Ubuntu] Memory 확인

    OS/Linux 2017. 1. 19. 11:59

    Ubuntu 환경에서 현재 메모리 사용량을 free 명령을 통해 알 수 있다.

    $ free -h

    total used free shared buff/cache available Mem: 7.8G 2.3G 3.6G 161M 1.9G 5.0G Swap: 46G 472K 46G



    $ free --help

    Usage: free [options] Options: -b, --bytes show output in bytes -k, --kilo show output in kilobytes -m, --mega show output in megabytes -g, --giga show output in gigabytes --tera show output in terabytes -h, --human show human-readable output --si use powers of 1000 not 1024 -l, --lohi show detailed low and high memory statistics -t, --total show total for RAM + swap -s N, --seconds N repeat printing every N seconds -c N, --count N repeat printing N times, then exit -w, --wide wide output --help display this help and exit -V, --version output version information and exit



    'OS > Linux' 카테고리의 다른 글

    [Ubuntu] hostname 변경  (0) 2017.01.19
    [Ubuntu] Word Count  (0) 2017.01.19
    [Ubuntu] Filesystem 용량 확인  (0) 2017.01.19
    [Ubuntu] 커널버전 및 Ubuntu 버전 확인  (0) 2017.01.18
    [Ubuntu] deb 파일 설치가 잘 안되는 경우  (0) 2017.01.05
    Posted by leechwin
    ,

    Ubuntu 환경에서 현재 Filesystem 사용량을 df 명령을 통해 알 수 있다.

    아래의 예제로는 현재 159G의 용량을 사용가능하다.

    $ df -h

    Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 794M 9.7M 785M 2% /run /dev/sda2 184G 16G 159G 10% / tmpfs 3.9G 86M 3.8G 3% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup tmpfs 794M 48K 794M 1% /run/user/1000

    $ df --help

    Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M) -H, --si print sizes in powers of 1000 (e.g., 1.1G) -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) --output[=FIELD_LIST] use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted. -P, --portability use the POSIX output format --sync invoke sync before getting usage info --total elide all entries insignificant to available space, and produce a grand total -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit Display values are in units of the first available SIZE from --block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page). GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Full documentation at: <http://www.gnu.org/software/coreutils/df> or available locally via: info '(coreutils) df invocation'


    'OS > Linux' 카테고리의 다른 글

    [Ubuntu] Word Count  (0) 2017.01.19
    [Ubuntu] Memory 확인  (0) 2017.01.19
    [Ubuntu] 커널버전 및 Ubuntu 버전 확인  (0) 2017.01.18
    [Ubuntu] deb 파일 설치가 잘 안되는 경우  (0) 2017.01.05
    [Jenkins] Jenkins 업데이트  (0) 2016.01.19
    Posted by leechwin
    ,