Ubuntu ๋ช ๋ น์ด ์ ๋ฆฌ
2022-10-20
- ๋ชฉ๋ก
- 0. ๊ธฐ๋ณธ ๋ช ๋ น์ด
-
- File ๋ฐ Directory
-
- ์กฐํ / ์ถ๋ ฅ / ํ์ผ ์์ฑ (
echo&touch&cat&redirection)
- ์กฐํ / ์ถ๋ ฅ / ํ์ผ ์์ฑ (
-
- System
Linux PC ์ค์น ํ ์ง๊ธ๊น์ง ์ผ๋ Ubuntu ๋ช ๋ น์ด ์ ๋ฆฌ
0. ๊ธฐ๋ณธ ๋ช ๋ น์ด
- ์ฌ๋ฌ ๋ช
๋ น์ด๋ค์ ๊ตฌ๋ถ
1m3rri17@:~/test$ echo command test;echo command test2 2test 3test2 - edit ๋ชจ๋์์ ์ ์ฅ ํ ์ข
๋ฃ(Not vi) :
Ctrl + D
1. File ๋ฐ Directory
pwd : Print working directory
1m3rri17@:~/test$ pwd 2/home/m3rri17/test
cd : Change directory
- cd / : move to
/ - cd ~ : move to
/home - cd .. : move to upper directory
- cd - : move to previous directory
ls : List segments
- ls -a : with hidden files
- ls -l : with detail information
[directory || file][permission] [*link count] [file owner] [file group owner] [size] [update date+time] [name of directory || file] - ls -t : order by update date desc
- ls -S : order by size desc (! upper case)
- ls -r : order by reversely
default name (z-aZ-A)
:grey_exclamation: ls -Sr > order by size asc - ls -i : with inode number
- ls ../ : execute
lsof parent directory - ls -p : with
/suffix - ls -R : with all directories and files of child directories
mv : Move
- mv file1 file2 : rename file file1 to file2 or overwrite file file1 to file2
1m3rri17@:~/test$ touch file1 && file2 2m3rri17@:~/test$ ls 3file1 file2 4m3rri17@:~/test$ mv file1 file2 5m3rri17@:~/test$ ls 6file2 - mv file1[ file2 ...] /dir1 : move file file1(+file2+...) to directory dir1
- mv /dir1 /dir2 : rename directory dir1 to dir2 or overwrite directory dir1 to dir2
- mv /dir1/* /dir2/ : move all of the contents of directory dir1 to dir2
1m3rri17@:~/test$ touch file{1..5} && mkdir dir1 2m3rri17@:~/test$ ls -RF 3.: 4dir1/ file1 file2 file3 file4 file5 5 6./dir1: 7m3rri17@:~/test$ mv file1 file5 ./dir1 8m3rri17@:~/test$ ls -RF 9.: 10dir1/ file2 file3 file4 11 12./dir1: 13file1 file5 14m3rri17@:~/test$ 15m3rri17@:~/test$ mv file{2..4} ./dir1 16m3rri17@:~/test$ ls -RF 17.: 18dir1/ 19 20./dir1: 21file1 file2 file3 file4 file5 22m3rri17@:~/test$ 23m3rri17@:~/test$ mv ./dir1 ./dir2 24m3rri17@:~/test$ ls 25dir2 26m3rri17@:~/test$ 27m3rri17@:~/test$ mkdir dir3 28m3rri17@:~/test$ mv ./dir2/* ./dir3/ 29m3rri17@:~/test$ ls -RF 30.: 31dir2/ dir3/ 32 33./dir2: 34 35./dir3: 36file1 file2 file3 file4 file5
rm : Remove
- rm file1 : remove file file1
rm ./* : remove all files in this directory - rm -r dir1 : remove directory dir1
1m3rri17@:~/test$ mkdir dir1 && touch ./dir1/file{1..3} 2m3rri17@:~/test$ rm ./dir1/file2 3m3rri17@:~/test$ rm -r dir1
2. ์กฐํ / ์ถ๋ ฅ / ํ์ผ ์์ฑ (echo & touch & cat & redirection)
echo : output command
1m3rri17@:~/test$ echo [option] [text]
- output variable or environment variable
1m3rri17@:~/test$ echo $PATH 2/usr/local/sbin:/usr/...~~ 3m3rri17@:~/test$ 4m3rri17@:~/test$ V_NAME=m3rri;V_TEXT="My name is" 5m3rri17@:~/test$ echo $V_TEXT $V_NAME 6My name is m3rri - output result of command
1m3rri17@:~/test$ echo PATH=$(echo $PATH) 2PATH=/usr/local/sbin:/usr/...~~ - using
"": long text or text included special token. ;, (, ), etc..1m3rri17@:~/test$ echo Multiple command strings are combined with \";\" or \"&&\". 2Multiple command strings are combined with " 3".: ๋ช ๋ น์ ์ฐพ์ ์ ์์ต๋๋ค 4m3rri17@:~/test$ echo Multiple command strings are combined with \"";"\" or \""&&"\".. 5Multiple command strings are combined with ";" or "&&". - options
-e: recognize escape character1m3rri17@:~/test$ echo "text1\ntext2" 2text1\ntext2 3m3rri17@:~/test$ echo -e "text1\ntext2" 4text1 5text2- use
help echo1m3rri17@:~/test$ echo --help 2--help 3m3rri17@:~/test$ help echo 4echo: echo [-neE] [์ธ์ ...] 5...
- create or update file using
redirectionecho "content" > filename
: Iffilenameexists, overwrite it withcontentor create a new fileecho "content" >> filename
: Iffilenameexists, appendcontenttofilenameor create a new file
1m3rri17@:~/test$ echo "start of content" > echo_test.txt 2m3rri17@:~/test$ cat echo_test.txt 3start of content 4m3rri17@:~/test$ echo "new start of content" > echo_test.txt 5m3rri17@:~/test$ cat echo_test.txt 6new start of content 7m3rri17@:~/test$ echo -e "\033[0;36m\$PATH\033[1;37m=$(echo $PATH)" >> echo_test.txt 8m3rri17@:~/test$ cat echo_test.txt 9new start of content 10$PATH=/usr/local/sbin:/usr/~~~
touch : generate 0 byte file
1m3rri17@:~/test$ touch testfile 2m3rri17@:~/test$ ls 3testfile
cat : con_CAT_enate. read + concatenate + write file
์ถ์ฒ : linuxize post
cat [options] [file names]- read file contents
1m3rri17@:~/test$ echo -e "linux\nubuntu" > catTest 2m3rri17@:~/test$ cat catTest 3linux 4ubuntu - redirect contents of file -> copy contents file to file using
redirection1m3rri17@:~/test$ ls 2catTest 3m3rri17@:~/test$ cat catTest > catTest2 4m3rri17@:~/test$ ls 5catTest catTest2 6m3rri17@:~/test$ cat catTest2 7linux 8ubuntu 9m3rri17@:~/test$ cat catTest >> catTest2 10m3rri17@:~/test$ cat -n catTest2 111 linux 122 ubuntu 133 linux 144 ubuntu - concatenate files : display concatenated contents of argument files
1m3rri17@:~/test$ cat test1 2concat test1 3m3rri17@:~/test$ cat test2 4concat test2 5m3rri17@:~/test$ cat test1 test2 6concat test1 7concat test2 8m3rri17@:~/test$ cat test1 test2 > test3 9m3rri17@:~/test$ cat test3 10concat test1 11concat test2 - create files
1m3rri17@:~/test$ cat > createCatTest.txt 2create cat test content 3m3rri17@:~/test$ cat createCatTest.txt 4create cat test content 5m3rri17@:~/test$ cat >> createCatTest.txt 6append text 7m3rri17@:~/test$ cat createCatTest.txt 8create cat test content 9append text - option
-n: print line numbers-s: ignore repeated empty lines1m3rri17@:~/test$ cat -n testfile 21 testline1 32 43 54 65 testline2 7m3rri17@:~/test$ cat -ns testfile 81 testline1 92 103 testline2-T: distinguish visually between tabs and spaces-e: display the each lines ending character$1m3rri17@:~/test$ cat testfile 2li nux 3ubu ntu 4m3rri17@:~/test$ cat -Te testfile 5li nux$ 6ubu^Intu$
3. System
filesystem mounted on directory
1m3rri17@:~/test$ df -h 2Filesystem Size Used Avail Use% Mounted on 3tmpfs 1.0G 2.7M 1.0G 1% /run 4... 5/dev/3 99G 5.2G 93G 5% /home 6...
/end of Ubuntu ๋ช
๋ น์ด ์ ๋ฆฌ
CONTENT LISTMERRI๏ผs DEVELOG
2022-11-09