linux-commands

pwd (print working directory)

# pwd
/root

cd (change directory)

# cd /etc
# pwd
/etc


# cd ..
# pwd
/

ls (list)

# ls

# ls -l

# ls -a

# ls -al

touch

# ls -l

# touch testfile

# ls -l

# touch testfile2

# ls -l

mkdir (make directory)

# ls

# mkdir testdir

# ls

testdir/  testfile  testfile2


# mkdir -p a/b/c/d/e/

# ls -R a/
a/:
b/

a/b:
c/

a/b/c:
d/

a/b/c/d:
e/

a/b/c/d/e:

cp (copy)

# cp testfile testfile_cp

# ls
testfile  testfile_cp

# mkdir testdir

# cp -r testdir testdir_cp
# ls
testdir/  testdir_cp/  testfile  testfile_cp

cat (concatenate)

# cat > file1
1
(ctrl + d)

# cat > file2
2
(ctrl + d)

# cat > file3
3
(ctrl + d)

# cat file1
# cat file2
# cat file3

# cat file1 file2 > file1_2
# ls
# cat file1_2
# cat file1 >> file2
# cat file2

head

# cat testfile
# head testfile
# head -3 testfile

tail

# cat testfile

# tail testfile

#tail -3 testfile

# tail -F testfile
(새로운 터미널로 접속해서 testfile의 값을 추가해서 확인)

#cat file1 >> testfile

find

# find /
# find / -type f
# find / -type d
# find / -type f -size +5M
#find ./ -name file1
#find / -name file1

grep

# find ./ -name '*' |xargs grep -n '1'