Вы находитесь на странице: 1из 5

Basic Commands

The must know commands fall in this category. I have distributed the commands
into two sub categories: Directory commands and File commands.
Directory Commands
pwd : Print working directory
mkdir : Create directories
cd : Change the current directory
rmdir : Remove directories
File Commands
ls : List directory contents
rm : Remove files
cp : Copy files from a source to the same or different target(s).
mv : Move file to different targets.
cat : Read one or more files and print them to standard output. If you need to
view contents of a short file, cat is recommended.
cmp: Compare two files byte by byte.
wc: Print the number of new lines, words, and bytes in files.
du : Estimate disk usage of each file and recursively for directories.
find: Search for files in directory hierarchy, e.g. find notes.txt
grep: Print lines matching a pattern,e.g. grep i topic notes.txt (topic is the pattern)
sort: Sort lines of text files
Editor
Every Linux program is an executable file. For instance, the cp command is provided
by the file in /bin/sh which holds the list of machine instructions. Similarly, if you are
installing a package , lets say vsftpd, your focus will be modifying its configuration
file , vsftpd.conf present in /etc directory. This is where you will be using editors.
I use Vim frequently. Its an advanced text editor that comes with a more complete
feature than the Vi text editor. The other text editors are: nano, vi, kate, (KDE
Advanced Text Editor), gedit (graphical user interface).
e.g. vim rabi.c ( vim filename ).
User Account
In linux, you can say that using the root account is like having the powers of God.
You will have access to almost each and every file(configuration files, system , text
files etc) with no interruption and restriction. You need to be very careful while doing

work as the root (super user). Therefore, managing user accounts and groups is an
essential part of a system administrator.
For example, an organization ABC has three departments: Marketing, Technical and
Account, each department having 3-4 employees. The organization demands you to
verify the users of marketing, technical and account departments so that the
employees of each group will be able to view his/her own department file.
Given a scenario, if you know how to manage these accounts, you can easily set
permissions for the users mentioned above. If not, these commands are essential for
the task.
useradd : for creating user account.
This command can be executed by administrators only. On debian, you should use
adduser. For other options like adding expiry date, home directory etc refer man
useradd.
passwd : for changing user password.
If the user has set password before, he/she will be prompted for the first password
whereas superuser is permitted to bypass the step so that forgotten passwords may be
changed.
You can find advices on how to choose a strong password on
http://en.wikipedia.org/wiki/Password_strength
usermod : modify user accoun.
userdel : delete a user account and related files
This command can be executed by administrators only.
groupadd : create a new group
groupdel : delete the group and entries referring to the group
groupmod : modify a group definition on the system
chmod : modify properties for users
chown : change file owner and group
chgrp : change group ownership
Network Commands
Linux is predominantly known for its use in servers. In 2009 it held a server market
share ranging between 2040%(source : wikipedia). One should know the commands
to check the ip address, download files from the net, get DNS, etc.

wget : a non-interactive network downloader


Even if a download fails due to a network problem, it will keep retrying until the
whole file has been retrieved. The server will instruct to continue to download from
where it it left off.
$ wget url-for-file
ping : send ICMP ECHO_REQUEST to network hosts, you will get back ICMP
packet if the host responds. This command is useful when you are in a doubt whether
your computer is connected or not.
$ ping IP or host name
hostname : show or set the systems host name
dnsdomainname : show the systems DNS domain name
netstat : displays the status of ports ie. which ports are open, closed, waiting for
connections. It displays the contents of /proc/net file.
ifconfig : configure a network interface, or to display their current configuration. It is
also useful to get the information about IP address, Subnet Mask,set remote IP address
, Netmask etc.
ifup : bring a network interface up
ifdown : take a network interface down
Archive Commands
You want to install a package from its source code. You find out that the source code
of the package is archived in a file xxx.tar. In this situation, the command-line utility
tar proves to be a vital resource for you. The tar is probably the most popular
Linux backup utility. If the tar file is compressed with the compression utility like
bzip or gzip, the resulting file is the famous tarballs which is a common method
to deliver software installation archives.
tar : an archiving program designed to store and extract files from an archive known
as a tarfile.
Options :
-c : create a new archive
-r : append files to the end of an archive

-t : list the contents of an archive


-u : only append files that are newer than copy in archive
-x : extract files from an archive
-C : change to directory Dir
-j : filter archive through bzip2, use to decompress .bz2 files.
-v : verbosely list files processed
-f : use archive file
-z : filter the archive through gzip
Examples: tar -xvf test.tar ( extract foo.tar to the current location)
tar -xvzf test.tar.gz ( extract gzipped test.tar.gz )
tar -cvf test.tar foo/ ( compress the contents of foo folder to foo.tar )
Help commands
There are manual pages for almost all the commands of Linux. You can access the
manual pages using man command. The man command offers documentation of the
command. If you type:
$ man ls
You will be seeing the manual page of ls with its name, synopsis, description, author,
copyright etc. Remember, there is a manual page for the man command itself.
If you desire to have a brief reference of the command, use -help option with the
command. $ ls -help
You can even use info command to have a quick overview of the command. $ info ls
Remember, that memorizing all the commands in Linux along with all its options is a
very difficult job. So memorise the command and options which has frequent usage
and leave the rest to the HELP commands.
Please go through below mention links as well.
http://www.fortystones.com/15-reasons-switch-linux/
http://www.fortystones.com/40-linux-shell-commands-beginners/
http://www.fortystones.com/basic-command-line-tips-tricks-ii/

http://www.fortystones.com/basic-networking-commands-linux/
http://www.fortystones.com/linux-file-types/

Вам также может понравиться