UNIX-1.11 zip, basename, mktemp, script and rcs commands


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

zip -r filename.zip file1 file2 file3 – zip and compress files, recursively
unzip filename.zip – unzip a zip file
rmdir dirname – remove empty directory
basename fullpath – returns the file or directory name
dirname fullpath – returns the directory
mktemp – creates a temporary file and outputs temp filename
factor number – list the factors of a number
script -a script.out – starts recording your output screen, ctrl+D to stop recording
kill %% – kills previous command
sudo apt-get install rcs – to install linux revision control system (RCS)
mkdir RCS – create a directory called RCS to store all versions of file
ci script.sh – checks in a file, file is not readable until checked out
ci -u script.sh – checks in a file, file is visible for others to read
co -l script.sh – checks out a file, holds the lock.
co -lr1.1 script.sh – checks out a version of file, holds the lock
rcsdiff script.sh – compares current file with latest checked in version
rcsdiff -r1.1 -r1.2 script.sh – compares version 1.1 and 1.2
which command – tells you where such command resides in
locate keyword – searches for files or paths that contains keyword (that are accessible to you)

Advertisements

UNIX-1.3 UNIX Commands and Options


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

du – data usage
du -sh – find how much disk space used in current directory

df – data file system
df -h – find disk space usage

cp – copies files
cp file1 file2 – copy file1 to file2
cp file1 dir/file2 – copy file1 to file2 in dir
cp file1 dir/ – copy file1 to dir with same filename
cp -rf dir1 dir2 – recursively copy dir1 to dir2
cp -i file1 file2 – prompt before overwriting file2
cp file1 file2 file3 dir1 – copy multiple files to a directory
cp -p file1 file2 – by default, permission is not preserved, use -p to do that
cp -s file1 link1 – create soft link to file1

mv – change/move files
mv file1 file2 – change filename from file1 to file2
mv -i file1 file2 – prompt before overwriting
mv file1 dir1 – move file1 to dir1
mv dir1 dir2 – move dir1 to dir2 if dir2 exists, else change name from dir1 to dir2

head – display lines in file from beginning
head file1 – display first 10 lines of file1
head -100 file1 – display first 100 lines of file1

tail – display lines in file from end
tail file1 – display last 10 lines of file1
tail -100 file1 – display last 100 lines of file1

rm – remove file or directory
rm file1 – remove file1
rm -rf dir1 – remove entire directory, never prompt
rm -i dir1 – prompt before removing

mkdir – create directory
mkdir dir1 – create dir1
mkdir -m777 dir1 – create dir1 with specified permission
mkdir -p dir1 – ignore error if dir1 already exists

tar – archive file
tar zcvf tarfilename.tar file1 file2 file3 – archive all these files into one tar ball, compressed
tar xvf tarfilename.tar – extract files from a tar ball
tar rf tarfilename.tar extra.txt – append extra.txt to existing tarfilename.tar (tarfilename.tar is not compressed)
tar tvf tarfilename.tar – list out files in tar ball

gzip – compress file
gzip file1 – compress file1, new filename will have .gz extension
gzip -d file1.gz – decompress file1.gz

chmod – change permission
chmod 777 file1 – change permission for file1 (rwxrwxrwx)
chmod +x file1 – give executable permission for all to file1 (+r, +w)
chmod u+x file1 – give executable permission for owner to file1 (g+x, o+x)
chmod -R 777 dir1 – change permission for all contents in dir1