Linux has tons of commands, but the ones described below are all you need for CMSC216.
% ls /* Files that start with a period (e.g., .aliases) are not listed */
% ls -al /* Long listing that also displays hidden files (those starting with a period) */
% ls -F /* Adds forward slash to identify directories */
% cd data_dir
% cd /* Takes you back to your home directory; great when you are lost */
% cd / /* Takes you to the root directory (under which all files/folder reside) */
% cd .. /* Takes you to the parent directory */
% cd ~/216public /* Takes you to the 216public directory that resides in the home directory */
% mkdir data_dir
% pwd
% nano my_prog.c
% cp my_prog.c my_copy.c
% cp my_prog.c data_dir /* Copies my_prog.c to the data_dir directory */
% cp my_prog.c .. /* Copies my_prog.c to the parent directory */
% cp /tmp/e.txt . /* Copies e.txt to current directory. Notice the period after e.txt */
% cp -r Week1 ~/216 /* Copies the directory Week1 to the folder 216 in the home directory */
% rm my_prog.c
% rmdir data_dir
% rm -f -r Week1
% mv my_prog.c my_prog_new_name.c
% mv my_prog.c data_dir
% less my_prog.c
% chmod 400 data.txt /* Only the owner (you) can read it */
% chmod 600 data.txt /* Only the owner (you) can read and write it */
% chmod 700 data.txt /* Only the owner (you) can read, write, and execute it */
% logout
% man ls
% diff file1 file2
% zip mydata.zip data1.txt data2.txt
For compressing a directory (e.g., material):
% zip -r material.zip material
To extract files:
% unzip mydata.zip
% tar czf grep_example.tar.gz grep_example
% tar xzf grep_example.tar.gz
% ln -s tmp/tasks
find . -name a.out -print
grep TODO *.c
scp terpito@grace.umd.edu:~/test.txt .
Here is another example where we want to transfer
the folder ~216public/projects/project1 present in the account of user terpito
(in the grace.umd.edu host) to your current folder (notice the period at the end):
scp -r terpito@grace.umd.edu:~/216public/projects/project1 .In the following example, we are transfering a folder to the ~/216 folder of the user terpito in the grace.umd.edu host:
scp -r sample_folder nelson@grace.umd.edu:~/216In both examples above, you can drop the -r option if you are transferring a single file.
man grep
% date /* Current date time */
% who /* Current users */
% ps /* Shows processes */
% emacs my_prog.c /* Popular editor */
% ls -al | less /* Using | to pipe output of one command as input to another */
% cal /* Calendar */
% ls *.txt /* Lists all files ending in .txt */
% cat data.txt /* Displays contents of a file (in this case data.txt) */