Linux all basics commands list in one Place , here is all:



      What is a command shell?



A program that interprets commands

Allows a user to execute commands by typing them manually at a terminal, or automatically in programs called shell scripts.



A shell is not an operating system. It is a way to interface with the operating system and run commands.



                What is BASH?



BASH = Bourne Again SHell

Bash is a shell written as a free replacement to the standard Bourne Shell (/bin/sh) originally written by Steve Bourne for UNIX systems.

It has all of the features of the original Bourne Shell, plus additions that make it easier to program with and use from the command line.

Since it is Free Software, it has been adopted as the default shell on most Linux systems.





              How is BASH different from the DOS command prompt?



Case Sensitivity:     In Linux/UNIX, commands and filenames are case sensitive, meaning that typing “ EXIT” instead of the proper “ exit” is a mistake.

\” vs. “ /”:      In DOS, the forward-slash “ /”  is the command argument delimiter,
while the backslash “ \”  is a directory separator.    In Linux/UNIX, the

/” is the directory separator, and the “ \” is an escape character. More about these special characters in a minute!

Filenames:                  The DOS world uses the “eight dot three” filename convention, meaning that all files followed a format that allowed up to 8 characters in the

filename, followed by a period (“dot”), followed by an option extension, up to 3 characters long (e.g. FILENAME.TXT). In UNIX/Linux, there is

no such thing as a file extension. Periods can be placed at any part of the filename, and “extensions” may be interpreted differently by all programs, or not at all.


                Special Characters

Before we continue to learn about Linux shell commands, it is important to know that there are many symbols and characters that the shell interprets in special ways. This means that certain typed characters: a) cannot be used in certain situations, b) may be used to perform special operations, or, c) must be “escaped” if you want to use them in a normal way.

Character

Description


\
Escape character.  If you want to reference a special character, you must “escape” it

with a backslash first.

Example:
touch /tmp/filename\*


/
Directory separator, used to separate a string of directory names.

Example:
/usr/src/linux


.
Current directory.  Can also “hide” files when it is the first character in a filename.


..
Parent directory


~
User's home directory


*
Represents 0 or more characters in a filename, or by itself, all files in a directory.

Example:
pic*2002 can represent the files pic2002, picJanuary2002,


picFeb292002, etc.


?
Represents a single character in a filename.

Example:
hello?.txt can represent hello1.txt, helloz.txt, but not


hello22.txt


[ ]
Can be used to represent a range of values, e.g. [0-9], [A-Z], etc.

Example:hello[0-2].txt represents the names hello0.txt,


hello1.txt, and hello2.txt


|
“Pipe”.  Redirect the output of one command into another command.

Example:
ls | more


> 
Redirect output of a command into a new file.  If the file already exists, over-write it.

Example:
ls > myfiles.txt


>> 
Redirect the output of a command onto the end of an existing file.

Example:echo “Mary 555-1234” >> phonenumbers.txt


< 
Redirect a file as input to a program.

Example:
more < phonenumbers.txt


;
Command separator.  Allows you to execute multiple commands on a single line.

Example:cd /var/log ; less messages


&&
Command separator as above, but only runs the second command if the first one

finished without errors.

Example:cd /var/logs && less messages


&
Execute a command in the background, and immediately get your shell back.

Example:
find / -name core > /tmp/corefiles.txt &





The Linux Directory Layout


Directory
Description





The nameless base of the filesystem.  All other directories, files, drives, and


devices are attached to this root.  Commonly (but incorrectly) referred to as


the “slash”  or “/”  directory.   The “/”  is  just  a directory  separator,  not a


directory itself.



/bin

Essential command binaries (programs) are stored here (bash, ls, mount,


tar, etc.)



/boot

Static files of the boot loader.



/dev

Device files.  In Linux, hardware devices are acceessd just like other files, and


they are kept under this directory.



/etc

Host-specific system configuration files.



/home

Location of users' personal home directories (e.g. /home/susan).



/lib

Essential shared libraries and kernel modules.



/proc

Process information pseudo-filesystem.  An interface to kernel data structures.



/root

The root (superuser) home directory.



/sbin

Essential system binaries (fdisk, fsck, init, etc).



/tmp

Temporary files.  All users have permission to place temporary files here.



/usr

The base directory for  most shareable, read-only data (programs, libraries,


documentation, and much more).



/usr/bin

Most user programs are kept here (cc, find, du, etc.).


/usr/include
Header files for compiling C programs.



/usr/lib

Libraries for most binary programs.


/usr/local
“Locally” installed files.  This directory only really matters in environments


where  files  are  stored  on  the  network.Locally-installed  files  go  in


/usr/local/bin,  /usr/local/lib,  etc.).    Also  often  used  for


software packages installed from source, or software not officially shipped


with the distribution.


/usr/sbin
Non-vital system binaries (lpd, useradd, etc.)


/usr/share
Architecture-independent data (icons, backgrounds, documentation, terminfo,


man pages, etc.).



/usr/src

Program source code.  E.g. The Linux Kernel, source RPMs, etc.


/usr/X11R6
The X Window System.



/var

Variable data: mail and printer spools, log files, lock files, etc.





                Commands for Navigating the Linux Filesystems

The first thing you usually want to do when learning about the Linux filesystem is take some time to look around and see what's there! These next few commands will: a) Tell you where you are,

b)  take you somewhere else, and c) show you what's there. The following table describes the basic operation of the pwd, cd, and ls commands, and compares them to certain DOS commands that you might already be familiar with.


Linux Command
DOS Command
Description





pwd
cd
“Print  Working  Directory”.
Shows  the  current


location in the directory tree.




cd
cd, chdir
“Change Directory”.  When typed all by itself, it


returns you to your home directory.



cd directory
cd directory
Change   into   the   specified   directory   name.


Example: cd /usr/src/linux



cd ~

“~” is an alias for your home directory.  It can be


used  as  a  shortcut  to  your  “home”,  or  other


directories relative to your home.



cd ..
cd..
Move up one directory.  For example, if you are in


/home/vic and you type “cd ..”, you will end


up in /home.





cd -

Return to previous directory.
An easy way to get


back to your previous location!




ls
dir /w
List  all  files  in  the  current  directory,  in  column


format.




ls directory
dir directory
List the files in the specified directory.


Example: ls /var/log




ls -l
dir
List files in “long” format, one file per line.  This


also shows you additional info about the file, such


as ownership, permissions, date, and size.



ls -a
dir /a
List all files, including “hidden” files.  Hidden files


are  those  files  that  begin  with  a  “.”,  e.g.  The


.bash_history file in your home directory.



ls -ld

A “long” list of “directory”, but instead of showing
directory

the directory contents, show the directory's detailed


information.  For example, compare the output of


the following two commands:



ls -l /usr/bin



ls -ld /usr/bin




ls /usr/bin/d*
dir d*.*
List all files whose names begin with the letter “d”


in the /usr/bin directory.






Unix/Linux Command Reference





File Commands




System Info


ls – directory listing


date – show the current date and time


ls -al
– formatted listing with hidden files


cal – show this month's calendar


cd dir
- change directory to dir


uptime
– show current uptime


cd – change to home


w – display who is online


pwd – show current directory


whoami
– who you are logged in as


mkdir dir
– create a directory dir


finger user
– display information about user


rm file – delete file


uname -a – show kernel information


rm -r dir
– delete directory dir


cat /proc/cpuinfo – cpu information


rm -f file
– force remove file


cat /proc/meminfo – memory information


rm -rf dir
– force remove directory dir *


man command
– show the manual for command


cp file1 file2 – copy file1 to file2


df – show disk usage


cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it


du – show directory space usage


doesn't exist


free – show memory and swap usage


mv file1 file2 – rename or move file1 to file2


whereis app
show possible locations of app


if file2 is an existing directory, moves file1 into


which app – show which app will be run by default


directory file2











Compression


ln -s file link – create symbolic link link to file






touch file
– create or update file


tar cf file.tar files – create a tar named





file.tar
containing files


cat > file – places standard input into file



tar xf file.tar – extract the files from file.tar

more file
– output the contents of file






tar czf file.tar.gz files – create a tar with

head file
– output the first 10 lines of file



tail file
– output the last 10 lines of file


Gzip compression




tar xzf file.tar.gz – extract a tar using Gzip

tail -f file – output the contents of file as it




grows, starting with the last 10 lines


tar cjf file.tar.bz2 – create a tar with Bzip2







compression






Process Management








tar xjf file.tar.bz2 – extract a tar using Bzip2


ps – display your currently active processes



gzip file – compresses file and renames it to


top – display all running processes


file.gz




kill pid – kill process id pid






gzip -d file.gz – decompresses file.gz back to


killall proc – kill all processes named proc *


file




bg – lists stopped or background jobs; resume a







stopped job in the background




Network


fg – brings the most recent job to foreground


ping host – ping host and output results


fg n – brings job n to the foreground


whois domain – get whois information for domain








dig domain – get DNS information for domain





File Permissions

chmod octal file – change the permissions of file


dig -x host
– reverse lookup host




wget file – download file

to octal, which can be found separately for user,





wget -c file – continue a stopped download


group, and world by adding:








4 – read (r)











Installation

2 – write (w)


Install from source:

  1 – execute (x)





./configure



Examples:











make




chmod 777 – read, write, execute for all








make install

chmod 755 – rwx for owner, rx for group and world





dpkg -i pkg.deb – install a package (Debian)


For more options, see man chmod.






rpm -Uvh pkg.rpm – install a package (RPM)











SSH














Shortcuts


ssh user@host – connect to host as user








Ctrl+C – halts the current command

ssh -p port user@host – connect to host on port




port as user



Ctrl+Z
– stops the current command, resume with





fg in the foreground or bg in the background


ssh-copy-id user@host – add your key to host for





user to enable a keyed or passwordless login


Ctrl+D
– log out of current session, similar to exit




Ctrl+W
– erases one word in the current line












Searching






Ctrl+U
– erases the whole line


grep pattern files – search for pattern in files








Ctrl+R
– type to bring up a recent command

grep -r pattern dir – search recursively for


!! - repeats the last command


pattern in dir









exit – log out of current session


command | grep pattern – search for pattern in the








output of command


* use with extreme caution.

locate file – find all instances of file



























































Techcindia