- PATH 변수 앞에 현재 디렉토리를 PATH 변수에 포함시키지 않는 이유... (보안상)


# useradd kkk

# cd ~kkk

# pwd

/home/kkk

# ls

rm -rf / 

# /bin/ls

ls

# /bin/ls -l

total 2

-rwxr-xr-x 1 kkk kkk 29 Mar 26 14:04 ls

# cat ls

-- ls --

#!/bin/sh

echo "rm -rf /"

-- ls --




- PATH 변수 뒤에도 포함시키지 않는 이유

# echo $PATH

/bin:/sbin:/usr/bin:/usr/sbin:.

# ls

ls*

# ./ls

rm -rf / 

# ls

ls*

# su - kkk

$ cp -a ls LS

$ ls

ls  LS

$ cp -a ls la

$ cp -a ls ld

$ cp -a ls ks

$ ls

ks  la  ld  ls  LS


# cd ~kkk

# LS

rm -rf / 

# la

rm -rf / 



# function myls(){

>   /bin/ls --color=tty

> }

[root@localhost ~]# myls

passwd100  passwd2  passwd3  passwd4

[root@localhost ~]# function ls(){

>   useradd kkk1

>   echo 1234|passwd --stdin kkk1 > /dev/null 2>&1

>   /bin/ls --color=tty

> }

# tail -1 /etc/passwd

avahi-autoipd:x:100:102:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin

# ls

passwd100  passwd2  passwd3  passwd4

# tail -1 /etc/passwd

kkk1:x:500:500::/home/kkk1:/bin/bash



# ssh kkk1@localhost

The authenticity of host 'localhost (127.0.0.1)' can't be established.

RSA key fingerprint is 00:48:f3:93:3c:12:8c:98:97:af:81:01:59:cf:c6:35.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'localhost' (RSA) to the list of known hosts.

kkk1@localhost's password: 




# ls

a.txt  ls*  mv*  mv2

# ls > list.txt

# ls -l

total 704

-rw-r--r-- 1 root root     21 Mar 27 11:46 a.txt

-rw-r--r-- 1 root root     27 Mar 27 11:49 list.txt

-rwxr-xr-x 1 root root  93566 Mar 27 11:45 ls*

-rwxr-xr-x 1 root root 111668 Mar 27 11:45 mv*

-rw-r--r-- 1 root root 467648 Mar 27 11:46 mv2

# cat list.txt 

a.txt

list.txt

ls*

mv*

mv2

# echo 123

123

# echo 123 > list.txt 

# cat list.txt 

123

# echo 456 >> list.txt 

# cat list.txt 

123

456



>와 >> 의 차이



- 모든 프로세스를 출력한다.

# ps aux

# ps -ef 



# ps aux | grep bash

# ps aux | grep tty




# grep root /etc/passwd

root:x:0:0:root:/root:/bin/bash

operator:x:11:0:operator:/root:/sbin/nologin

# awk /root/ /etc/passwd

root:x:0:0:root:/root:/bin/bash

operator:x:11:0:operator:/root:/sbin/nologin

# cat /etc/passwd | grep root

root:x:0:0:root:/root:/bin/bash

operator:x:11:0:operator:/root:/sbin/nologin

# cat /etc/passwd | awk /root/

root:x:0:0:root:/root:/bin/bash

operator:x:11:0:operator:/root:/sbin/nologin





- 마운트


- CD/DVD mount

1. DVD 삽입하고



2. 마운트 명령어로 DVD를 디렉토리 연결한다.


# ls -l /dev/cdrom

# mount -t iso9660 -o ro /dev/hdc /mnt

# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C

/dev/hdc               3831642   3831642         0 100% /mnt



# umount /dev/hdc

# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C



# mount  /dev/hdc /mnt

mount: block device /dev/hdc is write-protected, mounting read-only

# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C

/dev/hdc               3831642   3831642         0 100% /mnt

# umount /mnt

# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C





[root@localhost test]# ls -l /dev/hdc

brw-rw---- 1 root disk 22, 0 Mar 27 10:40 /dev/hdc

[root@localhost test]# ls -l /dev/cdrom

lrwxrwxrwx 1 root root 3 Mar 27 10:40 /dev/cdrom -> hdc

[root@localhost test]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C

[root@localhost test]# mount -t iso9660 -o ro /dev/cdrom /mnt

[root@localhost test]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C

/dev/hdc               3831642   3831642         0 100% /mnt

[root@localhost test]# umount /mnt

[root@localhost test]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              7103744   1797844   4939220  27% /

tmpfs                   257440         0    257440   0% /dev/shm

/root/c.dd                9677      9677         0 100% /root/C