반응형


유닉스 혹은 리눅스 기본 명령어 모음입니다. 모두 기본적인 파일 구조 명령어 들이라서 디렉토리(폴더) 만들어서 디렉토리 간 파일 이동, 삭제 등을 다룹니다.


유닉스나 리눅스에서는 프롬프트가 따로 친절히 경로를 표시해 주지 않아 마지막 부분에 프롬프트 변경 방식도 다뤄볼 예정입니다.


unix_tutorial_01.txt 파일의 내용은 아래와 같습니다.

Name: Ryan Heise
Email: ryan@ryanheise.com


터미널에서 명령어 연습을 한 로그를 모두 긁어 모은 형태 이므로 블록 글자들이 명령어고 바로 아래 내용들이 결과물입니다.


bash-4.1$ date
Wed Jul 30 12:25:57 EST 2014

bash-4.1$ echo hello
hello

bash-4.1$ cat /home/yobine/semester\ 2/Unix_tutorial/unix_tutorial_01.txt
Name: Ryan Heise
Email: rian@riunheise.com

bash-4.1$ cat /home/yobine/semester\ 2/Unix_tutorial/unix_tutorial_01.txt /home/yobine/semester\ 2/Unix_tutorial/unix_tutorial_01.txt
Name: Rian Heise
Email: rian@riunheise.com

Name: Rian Heise
Email: rian@riunheise.com

bash-4.1$ cd /home/yobine/semester\ 2/Unix_tutorial/
bash-4.1$ ls
unix_tutorial_01.txt

bash-4.1$ pwd
/home/yobine/semester 2/Unix_tutorial
bash-4.1$ cd
bash-4.1$ pwd
/home/yobine
bash-4.1$ cd ..
bash-4.1$ ls
yobine
bash-4.1$ pwd
/home
bash-4.1$ cd /
bash-4.1$ pwd
/

bash-4.1$ ls
bin   cgroup  etc   images  lib64    media  mnt  opt   pub    sbin     srv  tmp  var
boot  dev     home  lib     lost+found    misc   net  proc  root    selinux  sys  usr

bash-4.1$ whoami
yobine


bash-4.1$ cd /home/Heise
bash-4.1$ ls
ls: cannot open directory .: Permission denied

bash-4.1$ pwd
/home/Heise


bash-4.1$ cd /
bash-4.1$ ls
bin   cgroup  etc   images  lib64    media  mnt  opt   pub    sbin     srv  tmp  var
boot  dev     home  lib     lost+found    misc   net  proc  root    selinux  sys  usr
bash-4.1$ pwd
/
bash-4.1$ cd
bash-4.1$ pwd
/home/yobine
bash-4.1$ cd semester\ 2/Unix_tutorial/
bash-4.1$ ls
a.txt  b.txt  unix_tutorial_01.txt  unix_tutorial_01.txt~

bash-4.1$ groups
Students

bash-4.1$ ls -l
total 5
-rw-r--r--+ 1 yobine Students  44 Jul 30 12:13 a.txt
-rw-r--r--+ 1 yobine Students  44 Jul 30 12:13 b.txt
-rw-r--r--+ 1 yobine Students 918 Jul 30 12:40 unix_tutorial_01.txt
-rw-r--r--+ 1 yobine Students  44 Jul 30 12:13 unix_tutorial_01.txt~


bash-4.1$ ls -l /
total 108
dr-xr-xr-x.   2 root root  4096 Jun 23 12:39 bin
dr-xr-xr-x.   4 root root  4096 Feb 12 06:24 boot
drwxr-xr-x    2 root root  4096 Dec  3  2013 cgroup
drwxr-xr-x   19 root root  3860 Jul 30 10:17 dev
drwxr-xr-x. 131 root root 12288 Jul 30 12:41 etc
drwxr-xr-x    4 root root     0 Jul 30 12:41 home
drwxr-xr-x.  15 root root  4096 Jul 30 12:01 images
dr-xr-xr-x.  13 root root  4096 Jun 23 12:38 lib
dr-xr-xr-x.  10 root root 12288 Jun 23 12:38 lib64
drwx------.   2 root root 16384 Feb  6  2013 lost+found
drwxr-xr-x.   2 root root  4096 Jun  5 16:00 media
drwxr-xr-x    2 root root     0 Jul 30 10:17 misc
drwxr-xr-x.   2 root root  4096 Jun 29  2011 mnt
drwxr-xr-x    2 root root     0 Jul 30 10:17 net
drwxr-xr-x.  23 root root  4096 Jul 29 12:38 opt
dr-xr-xr-x  243 root root     0 Jul 30  2014 proc
drwxr-xr-x    2 root root     0 Jul 30 10:17 pub
drwx------.  10 root root  4096 Jul 16 12:06 root
dr-xr-xr-x.   2 root root 12288 Jun 23 12:38 sbin
drwxr-xr-x.   2 root root  4096 Feb  6  2013 selinux
drwxr-xr-x.   2 root root  4096 Jun 29  2011 srv
drwxr-xr-x   13 root root     0 Jul 30  2014 sys
drwxrwxrwt.  26 root root  4096 Jul 30 12:47 tmp
drwxr-xr-x.  16 root root  4096 Jul 22  2013 usr
drwxr-xr-x.  23 root root  4096 Jul 18 07:10 var

bash-4.1$ ls -l /home/yobine/semester\ 2/
total 2
drwxr-xr-x+ 2 yobine Students 6 Jul 30 12:45 Unix_tutorial

bash-4.1$ mkdir usp
bash-4.1$ ls
cnsql.sh  nasa2.sql~  newls.sh~   semester 2  usp       workspace
Desktop   new file~   semester 1  sql.sh~     vpworkspace

bash-4.1$ cd usp
bash-4.1$ ls
bash-4.1$ mkdir 1
bash-4.1$ mkdir 2 3 4 5 6 7
bash-4.1$ ls
1  2  3  4  5  6  7

bash-4.1$ pwd
/home/yobine/usp

bash-4.1$ cd 1
bash-4.1$ touch hello.txt
bash-4.1$ ls
hello.txt
bash-4.1$ touch a.txt b.txt c.txt

bash-4.1$ ls -l
total 2
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 a.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 b.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 c.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:54 hello.txt

bash-4.1$ touch hello.txt //creates file but also changes the modification date (update dates)

bash-4.1$ ls -l
total 2
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 a.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 b.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 c.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 hello.txt

bash-4.1$ cp a.txt mycopy.txt
bash-4.1$ ls -l
total 3
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 a.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 b.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 c.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 hello.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:59 mycopy.txt

//move files to other directories, but in the same directory, it changes the name of the file.
bash-4.1$ mv b.txt newname.txt
bash-4.1$ ls -l
total 3
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 a.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 c.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 hello.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:59 mycopy.txt
-rw-r--r--+ 1 yobine Students 0 Jul 30 12:56 newname.txt

bash-4.1$ mv newname.txt /home/yobine/newname.txt
bash-4.1$ mv newname.txt ../../newname.txt

bash-4.1$ cd ..
bash-4.1$ pwd
/home/yobine/usp


bash-4.1$ cd 1/../2/../../usp/1
bash-4.1$ pwd
/home/yobine/usp/1
bash-4.1$ ls
a.txt  c.txt  hello.txt  mycopy.txt  newname.txt

bash-4.1$ cp a.txt c.txt ../2
bash-4.1$ ls
a.txt  c.txt  hello.txt  mycopy.txt  newname.txt

bash-4.1$ ls ../2
a.txt  c.txt

bash-4.1$ cd ../2
bash-4.1$ pwd
/home/yobine/usp/2
bash-4.1$ ls
a.txt  c.txt

//to change the root prompt with a view,
//try man bash and search for PROMPTING (/PROMPTING)

반응형

+ Recent posts