The following opinions expressed in this post are my own and in no way connected to my employer.
Commands in a Glimpse (a basic few)
A glimpse on the few widely used unix or linux commands (few are out of date and few need root access)
Use man command to view details on any command
man manual; acts as a manual to view info on all commands
cal | calender; to display calender |
passwd | password; to change password of current user |
ls | list all files and directories |
whoami | list account name associated with current login |
users | list all users logged in at same time |
who | list all users logged in at same time |
w | list all users logged in at same time with additional info |
logout | system will cleanup everything and break the connection |
halt | Brings the system down immediately |
init 0 | Powers off the system using predefined scripts to synchronize and clean up the system prior to shutdown |
init 6 | Reboots the system by shutting it down completely and then bringing it completely back up |
poweroff | shuts down the system by powering off |
reboot | reboots the system |
shutdown | shuts down the system |
cp | copy |
mv | move or rename |
rm | remove |
wc | word count |
cd | change directory |
mkdir | make directory |
rmdir | remove directory |
chmod | to change permissions on files and directories |
chown | change owner of a file or directory |
chgrp | change group of a file or directory |
echo | to print a text/variable |
grep | to find a text/string/charecter pattern |
lp,lpr | to print a file on paper opposed to screen |
lpstat | to view info on printer queue |
mail,mailx | to send mail |
| | to concatenate multiple unix commands ( cat file|wc -l) |
ps | gives detail on processes running |
scp | server copy; to copy from 1 server to other |
ping | to check response from a host server |
ftp | to transfer files (upload/download) from 1 computer to other |
telnet | to connect to a server on another site and work, also used to test connectivity |
finger | displays info of a user on a particular host |
Commonly used commands and their use:
ls -ltr | lists the files in reverse time order i.e, latest files listed last |
ls -la | lists the files including the hidden files |
ls -lh | lists the files with size in human readable format |
ls -ld | lists the directory details |
lp filename | prints the output of file on paper via default printer |
lp -d printername filename | prints to specified printer |
lpr -p printername filename | prints to specified printer |
lpstat -o | displays all jobs in printer queue |
lpq | displays printer job information in a different format |
mailx -s "subject" emailid | sends mail to email id with subject specified in -s |
uuencode file|mailx emailid | sends file as an attachment to email id specified |
ls -l|grep Aug|sort +4n | list files after filtering Aug containing lines and sorts 4th column ignoring the tabs and blanks |
PING - sends an echo request to remote host on the network
ping hostname
It is useful when:
Tracking and isolating hardware/software problems
Testing/managing the network/remote host
FTP Utility (file transfer protocol) - connects to remote host and enables to upload/download files from/to remote host
ftp hostname
FTP has its own set of commands:
connect and login to remote host
navigate directories
list directory contents
put and get files
transfer files as ASCII/binary/ebcdic
put filename | upload file from local to remote machine |
get filename | download file from remote to local machine |
mput filelist | upload more than 1 file from local to remote machine |
mget filelist | download more than 1 file from remote to local machine |
prompt on | turns prompt on |
dir | lists all files in current directory |
cd dirname | change directory in remote machine |
lcd dirname | change directory in local machine |
quit | logout from current login |
Eg:
ftp hostname
name: username
password:
(logged in)
dir
drwxrwxrwx user1 group1 abc
cd abc
dir
-rwxrwxrwx user1 group1 file1.txt
get file1.txt
bye (quit)
TELNET Utility - Provides utility to connect to a computer at another site and work.
telnet hostname
login : user1
password:
$ logout
Also helps in determining if ports are open between source and destination using below as
Eg:
telnet hostname 1521
Comments