This document provides a tutorial on basic Unix/Linux commands for directories, files, and other system operations. It covers commands for making and deleting directories, listing and copying files, searching and compressing files, running processes in the background, viewing command history, and checking available disk space. The tutorial is organized into sections on directories, files, and miscellaneous commands.
This document provides a tutorial on basic Unix/Linux commands for directories, files, and other system operations. It covers commands for making and deleting directories, listing and copying files, searching and compressing files, running processes in the background, viewing command history, and checking available disk space. The tutorial is organized into sections on directories, files, and miscellaneous commands.
School of Electronics and Computer Engineering Technology
Seneca College of Applied Arts and Technology
Ver. 0.1
1. Directory: 1.1 Make Directory
% mkdir <dir> # create directory <dir>
1.2 Delete Directory
% rmdir <dir> # delete directory <dir>
1.3 Change Directory
% cd <dir> # change to directory <dir>
% cd . # change to current directory % cd .. # change to parent directory
1.4 Display Current Directory
% pwd # display current directory path
2. Files 2.1 List Files
% ls # list files of current directory
% ls –a # list files (include hidden) of current directory % ls –l # list files of current directory in long list format % ls –lrt # list files of current directory in long list format with order % ll # ls –l alias command % ls <dir> # list files of sub-directory <dir> % ls . # list files of current directory % ls .. # list files of parent directory % ls ~ # list files of home directory % ls ~/<dir> # list files of sub-directory under home directory
2.2 Copy Files
% cp <file1> <file2> # copy <file1> to <file2>
% cp <dir>/<file> . # copy <file> from <dir> to current directory % cp <dir1>/<file> <dir2> # copy <file1> from <dir1> to <dir2>
2.3 Move Files
% mv <file1> <file2> # rename <file1> to <file2>
% mv <dir>/<file> . # move file form <dir> to current directory
2.4 Delete Files
% rm <file> # delete <file>
% rm * # delete all files using wild card % rm –r * # delete all files using wild card without warning % rm [a-z]* # delete all file start with a to z
2.5 Concatenate Files
% cat <file> # display file on screen
% cat <file1> <file2> > <file3> # concatenate <file1> and <file2> to <file3>
2.6 Display File
% more <file> # display file on screen
% view <file> # view file on screen
2.6 Modify Files Security
% chmod <file> <cmd> # modify <file> security with <cmd> where <cmd> <ugoa><+/-><rwx> % chmod –R <cmd> <dir> # modify all file security under <dir> with <cmd>
2.7 Difference between Files
% diff <file1> <file2> # difference between <file1> <file2>
2.8 Search File
% find –name “<file>” –print # find <file> in all subdirectory
2.9 Compress File
% gzip <file> # compress file using gzip command
% gzip –f <dir> # compress all files under <dir> directory % gunzip <file> # uncompress file using gunzip command % gunzip –f <dir> # uncompress all files under <dir> directory % tar –cvf <file> <dir> # compress all files under <dir> to file <file> % tar –xvf <file> # uncompress file <file> % tar –tvf <file> # list all files in uncompressed file <file> 3. Miscellaneous 3.1 Clear Screen
% clear # clear screen
3.2 Redirect
% <cmd> > <file> # redirect <cmd> results to <file>
% <cmd> >> <file> # append <cmd> results to <file> % <cmd> < <file> # execute <cmd> from <file>
3.3 Pipe
% <cmd1> | <cmd2> # direct <cmd1> results to <cmd2>
3.4 Process
% ^c # kill current command by Control-C
% ^z # stop current command by Control-Z % <cmd> & # run <cmd> in background % bg # run command stop by Control-Z in background % fg # foreground command in background % jobs # list all background jobs % kill # kill the background jobs % kill -9 <jobs> # kill the background jobs without warning
3.5 History
% history # list command history
% !! # execute last command % !<#number> # execute <#number> command in history list
3.6 System
% df # list space left on file system
% du * # list summary of file size in kilobyte % du –s * # list summary of subdirectory size in kilobyte