Linux Day2
Linux directory structure
/ : "root", the top of the file system hierarchy
/bin : Binaries and other executable programs
/etc : System configuration files
/home : Home directories (/home/callie => 내 account 데이터를 저장)
/opt : optional or third party software. (sw that is not bundled with the OS)
/tmp : Temporary space, typically cleared on reboot
/usr : User related programs
/var : Variable data, most notably log files
/var/log : Log files
/boot : Files needed to boot the operating system
/cdrom : Mount point for CD-ROMs.
/dev : device files, typically controlled by the OS and the sys admin
/export : shared file systems
/lib : system libraries
/lib64 : system libraries, 64bit
/lost+found : Used by the file system to store recovered files after a file system check has been performed.
/media : Used to mount removable media like CD-ROMs
/mnt : Used to mount external file systems
/proc : Provides info about running processes
/sbin : System administration binaries
/selinux : Used to display information about SELinux
usr/local : Locally installed software that is not part of the base operating system.
Application Directory Structures
Applicatinos that are not part of the base OS can be installed in
/usr/local /opt
usr/local/SWname/
/usr/local/crashplan/bin
/usr/local/crashplan/etc
/usr/local/crashplan/lib
/usr/local/crashplan/log
Shell
- The default interface to Linux
- CLI VS GUI
- The command line is more powerful
- There will always be a command line
- Server distributions do not include GUIs.
- Desktop distributions have GUIs and CLIs
- The prompt
- $ : Normal user
- # : Super user root@linuxsvr (superuser account)
- Tilda Expansion
- ~callie = /home/callie
- ~pat = /home/pat
- ~root = /root
- ~ftp = /srv/ftp
Basic linux commands
ls : Lists directory contents
cd : Changes the curreent directory
pwd : Displays the present working directory
cat : Concatenates and displays files
echo : Displays arguments to the screen
man : Displays the online manual
exit : Exits the shell or your current session
clear : Clears the screen
man cmd 하면 정보 나옴 다 봤으면 q 치고 나간다. man ls 이렇게
PATH
- An environment variable
- Controls the command search path
- Contains a list of directories
which
- Locate a command
cd /bin
man 명령어
How to use directory shortcuts
. : This directory
.. : The parent directory
cd - : Change to the previous dirctory
How to execute commands outside of $PATH
- $PATH 안에 있는 디렉토리의 명령어라면 , 어디에든지 불러도 실행된다.
- ./(디렉토리에 있는 명령어) : 이렇게 실행 가능하다.
How to create and remove directories
mkdir [-p] directory : Create a directory
rmdir [-p] directory : Remove a directory
rm -rf directory : Recursively removes directory
- -p 넣으면 /a/b 이렇게 만들면 a 패런트 디렉토리도 만들어준다.
mkdir dir1/dir2/dir3 : 오류 뜬다.
mkdir -p dir1/dir2/dir3 : 정상 실행됨.
ls
ls -l : 파일 정보
ls -a : hidden file까지 보여줌
ls -al : 이렇게 한번에 할 수 있다.
ls -F : 파일, 디렉토리 타입 알려준다. / : 디렉토리, @ : link , * : 실행가능한
Permission, Number of links, Owner name, Group name, Number of bytes in the file, Last modification time, File name
ls -t : list files by time
ls -r : reverse order
ls -latr : Long listing including all files reverse sorted by time
ls -R : lists files recursively
ls -R은 tree와 비슷하다. tree -d(디렉토리만), tree -C(colored)와 미슷하다.
이름에 스페이스가 있을 때, ““를 이용한다.
ls -l "my notes.txt"