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.8 ps, netstat, kill, pidof, fuser, awk 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

ps -fu username – displays all processes started by user
ps -ef – display all processes running
ps -ef | grep ‘pname’ – look for specific process
netstat -t – see all tcp connections
netstat -an – see all network connections
netstat -c – netstat will execute every second
netstat -p – display processes that use these connections
kill pid – kills process by pid
kill -9 pid – force kill process by pid
& – execute process in background
free – show memory usage, alternatively use top
pidof command – shows process id for running process/command
fuser -vu dir – displays all processes that are using dir, along with owner id of processes
echo “hello world” | awk ‘{ print length($1) }’ – prints length of field
echo “hello world” | awk ‘{ print substr($1, 3) }’ – prints llo, substring function
echo “hello world” | awk ‘{sub(regex, replacement); print}’ – replace pattern on line and print
echo “HELLO world” | awk ‘{ print tolower($1) }’ – lower case field 1
echo “hello world” | awk ‘{ print toupper($1) }’ – upper case field 1