cd : move to a directory
cd /usr/bin/
move to /usr/bin/ directory.
cd
move to the home directory.
cd ~
also move to the home directory.
cd ..
move to the parent directory.
ls : list files and directories in the current directory
ls -a
list including files and directories which start with ".".
ls -l
list with more detailed information (e.g., file permission, ownership, size, last modified time, etc.).
ls -al
list with more detailed information including files and directories which start with ".".
ll
this is a shortcut of "ls -al".
mv : move a file to a specified directory or rename a file
mv hello.c /path/to/dir/
move hello.c under the directory /path/to/dir/.
mv hello.c ./dir/
move hello.c under the directory dir/ which exists on the current directory (".").
mv /path/to/dir/hello.c /another/path/to/dir/
move hello.c which is under the /path/to/dir/ directory to the another directory, /another/path/to/dir/.
mv /path/to/dir/hello.c .
move hello.c which is under the /path/to/dir/ directory to the current directory (".").
mv hello.c new_hello.c
rename hello.c to new_hello.c.
mv hello.c /path/to/dir/new_hello.c
move hello.c under the directory /path/to/dir/ and rename it into new_hello.c.
mv /path/to/dir/ /another/path/to/dir/
move the whole directory /path/to/dir/ as /another/path/to/dir/.
cp : copy a file under a directory
cp hello.c /path/to/dir/
copy hello.c under the directory /path/to/dir/.
cp hello.c new_hello.c
copy hello.c and name the new file as new_hello.c.
cp -r /path/to/dir/ /another/path/to/dir/
copy the whole directory /path/to/dir/ under the directory /another/path/to/dir/. -r means "recursively".
rm : remove a file
BE CAREFUL IN USING rm : REMOVED FILES CAN NEVER BE REVIVED
rm hello.c
remove hello.c.
rm -d /path/to/dir/
remove an empty directory /path/to/dir.
rm -r /path/to/dir/
remove /path/to/dir/ directory and all files under the directory.
mkdir : make a new directory
mkdir /path/to/dir/
make a new directory, /path/to/dir/. The /path/to/ directory should already exist.
mkdir dir/
make a new directory dir/ under the current directory.
mkdir -p /path/to/dir/
make a new directory, /path/to/dir/. If parent directories such as /path/ or /path/to/ doesn't exist, make them also.
rmdir : remove an empty directory
rmdir /path/to/dir/
remove /path/to/dir/ directory if empty.
rmdir -p /path/to/dir/
remove /path/to/dir/ and all of its parent directories, such as /path/ or /path/to/. In this case, it will try to remove the root directory, /, because it is also one of the parent directories. This means you are trying to remove all of your file system! (which will not work properly.)
rmdir -p path/to/dir/
Now this command doesn't start from the root directory, thus it is more plausible than the command above. It removes path/to/dir/, path/to/, and path/ directories.
cat : write contents of a file to stdout stream.
cat hello.c
show contents written in hello.c on the console. (To be more specific, it writes contents in hello.c to stdout stream.)
cat -n hello.c
show contents written in hello.c on the console with line numbers.
ping : check whether a host (or an IP address) is accessible
ping www.kaist.ac.kr
check whether you can access to www.kaist.ac.kr.
ping eelab1.kaist.ac.kr
check whether you can access to eelab1.kaist.ac.kr.
ssh : access a host via ssh protocol. you login to the host remotely in a secure manner (all communication between your machine and the remote host is encrypted). ssh = secure shell
ssh 20160001@eelab1.kaist.ac.kr
access to eelab1.kaist.ac.kr with the account 20160001.
scp : copy a file to a host via ssh protocol
scp hello.c 20160001@eelab1.kaist.ac.kr:
copy hello.c file in the current directory to the home directory of the account 20160001 in the eelab1.kaist.ac.kr machine.
scp 20160001@eelab1.kaist.ac.kr:ee209_assign1/hello1.c .
copy ee209_assign1/hello.c under 2016001's home directory at eelab1.kaist.ac.kr to the current directory (".") of my local machine.
scp -r dir/ 20160001@eelab1.kaist.ac.kr:
copy dir/ directory under the current directory to the home directory of the account 20160001 in the eelab1.kaist.ac.kr machine.
wget : download a file from web
wget https://www.ndsl.kaist.edu/ee209/assignment/wc209/files/sample209
Download the sample binary for assignment 1.
man : show UNIX & LINUX manual
man cp
show the manual of cp command.
man printf
show the manual of printf function.