Unix Commands
Unix Commands
Command Description
cat file1 file2 > file3 Joins two files (file1, file2) and stores the
output in a new file (file3)
mv file "new file path" Moves the files to the new location
mv Renames a directory
mail -s "Subject" to-address < Filename Command to send email with attachment
diff filename1 filename2 --- compares files, and shows where they differ
wc filename --- tells you how many lines, words, and characters there are in
a file
chmod options filename --- lets you change the read, write, and execute
permissions on your files.
chmod o+r filename will make the file readable for everyone
chmod o-r filename will make it unreadable for others again.
gzip filename --- compresses files
gunzip filename --- uncompresses files compressed by gzip
gzcat filename --- lets you look at a gzipped file without actually having to gunzip
it
Finding things
ff --- find files anywhere on the system.
grep string filename(s) --- looks for the string in the files.
Finding People
w --- tells you who's logged in, and what they're doing.
who --- tells you who's logged on, and where they're coming from.
finger username --- gives you lots of information about that user
last -1 username --- tells you when the user last logged on and off and from
where.
talk username --- lets you have a (typed) conversation with another user
write username --- lets you exchange one-line messages with another user
elm --- lets you send e-mail messages to people around the world
Name default ports used for DNS, SMTP, FTP, SSH, DHCP
and squid.
Servic
Port
e
DNS 53
SMTP 25
20 (Data transfer), 21 (Connection
FTP established)
SSH 22
67/UDP (dhcp server), 68/UDP (dhcp
DHCP client)
squid 3128
Why is the tar command used?
Suppose you want to extract all the files from the archive named sample.tar.gz,
then the command will be
Every process has a unique process id. To terminate the process, we first need
to find the process id. The ps command will list all the running processes along
with the process id. And then we use the kill command to terminate the
process.
$ ps
$ kill 3849
The touch command can be used to create a text file without opening it.
The touch command will create an empty file. The syntax is as follows:
$ touch <filename>
free -m
vmstat
top
htop
Grep stands for Global Regular Expression Print. The grep command is used
to search for a text in a file by pattern matching based on regular expression