Business

Monday 7 April 2014

Linux commands and bash shell commends with tutorial

Posted by techblown
Many of People don't know what is Linux and what is the value of linux. They think about linux is it is a free and open source operating system and it is only useful for Professional work it is not for entertainment.Yes actually Linux os is Mainly for Professional work and little bit Entertainment purpose. It is hack proof and and easy interface it's main advantage is MULTI TASKING. Use Linux for Multi tasking and Hack proof Operating system very useful for Every User.
                                                         


                  

Here i am giving All Linux basic and Bash shell commands and All commands also with exolaining. Linux was originally developed as a free operating system for Intel x86-based personal computers. It has since been ported to more computer hardware platforms than any other operating system. It is a leading operating system on servers and other big iron systems such as mainframe computers and supercomputers as of June 2013, more than 95% of the world's 500 fastest supercomputers run some variant of Linux, including all the 44 fastest. Linux also runs on embedded systems (devices where the operating system is typically built into the firmware and highly tailored to the system) such as mobile phones, tablet computers, network routers, building automation controls, televisions and video game consoles. the Android system in wide use on mobile devices is built on the Linux kernel.



Linux Operating supported Devices:

  • Intel Based all boards
  • Mac osx all 
  • Nokia N700,N800,N900 mobiles
  • Nokia N9
  • Upcoming Ubuntu Mobile
  • Nokia N710
  • Tablets
Recentlty announced Ubuntu OS for Mobile it is comming soon to mobile world. Sleek design and Good fron facing camera and High processor and Good RAM and stunning LED display slim and sleek design.
                  

Linux Useful Commands:


Shorthand at the Command Prompt

Some of these are specific to the bash shell. I have not experimented enough with other shells to know which are common to all shells. See also the ``Bash Reference Card'', SSC (2000), available online.


/ - root directory


./ - current directory


./command_name - run a command in the current directory when the current directory is not on the path


../ - parent directory


~ - home directory


$ - typical prompt when logged in as ordinary user


# - typical prompt when logged in as root or superuser


! - repeat specified command


!! - repeat previous command


^^ - repeat previous command with substitution


& - run a program in background mode


[Tab][Tab] - prints a list of all available commands. This is just an example of autocomplete with no restriction on the first letter.


x[Tab][Tab] - prints a list of all available completions for a command, where the beginning is ``x''


[Alt][Ctrl][F1] - switch to the first virtual text console


[Alt][Ctrl][Fn] - switch to the nth virtual text console. Typically, there are six on a Linux PC system.


[Alt][Ctrl][F7] - switch to the first GUI console, if there is one running. If the graphical console freezes, one can switch to a nongraphical console, kill the process that is giving problems, and switch back to the graphical console using this shortcut.


[ArrowUp] - scroll through the command history (in bash)


[Shift][PageUp] - scroll terminal output up. This also works at the login prompt, so you can scroll through your boot messages.


[Shift][PageDown] - scroll terminal output down


[Ctrl][Alt][+] - switch to next X server resolution (if the server is set up for more than one resolution)


[Ctrl][Alt][-] - change to previous X server resolution


[Ctrl][Alt][BkSpc] - kill the current X server. Used when normal exit is not possible.


[Ctrl][Alt][Del] - shut down the system and reboot


[Ctrl]c - kill the current process


[Ctrl]d - logout from the current terminal


[Ctrl]s - stop transfer to current terminal


[Ctrl]q - resume transfer to current terminal. This should be tried if the terminal stops responding.


[Ctrl]z - send current process to the background


reset - restore a terminal to its default settings


[Leftmousebutton] - Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode.


[Middlemousebutton] - Copies text from the text buffer and inserts it at the cursor location. With a two-button mouse, click on both buttons simultaneously. It is necessary for three-button emulation to be enabled, either under gpm or in XF86Config.

Typical Dot Files


There is some redundancy across these programs. For example, the look and behavior of emacs can be customized by usinng the .emacs file, but also by adding the appropriate modifications to the .Xdefaults file. Default versions of these files are often installed in users' home directories when the software packages that use them are installed. If a program doesn't find its configuration file in the user's home directory, it will often fall back on a sytem-wide default configuration file installed in one of the subdirectories that the package lives in.

.bash_logout - file executed by bash shell on logout

.bash_profile - initialization of bash shell run only on login. Bash looks first for a .bash_profile file when started as a login shell or with the -login option. If it does not find .bash_profile, it looks for .bash_login. If it doesn't find that, it looks for .profile. System-wide functions and aliases go in /etc/bashrc and default environment variables go in /etc/profile.

.bashrc - initialization command run when bash shell starts up as a non-login shell


.cshrc - initialization commands that are run automatically (like autoexec.bat) when C shell is initiated


.emacs - configuration file for emacs editor


.fvwmrc - configuration file for fvwm window manager


.fvwm2rc - configuration file for fvwm2 window manager


.jedrc - configuration file for the jed text editor


.lessrc - typically contains key bindings for cursor movement with the less command


.login - initialization file when user logs in


.logout - commands run when user logs out


.wm_style - gives choice of default window manager if one is not specified in startx


.Xdefaults - sets up X resources for individual user. The behavior of many different application programs can be changed by modifying this file.


.xinitrc - initialization file when running startx. Can be used to activate applications, run a given window manager, and modify the appearance of the root window.


.xsession - configuration file for xdm


Useful Files:

/boot/vmlinuz - the typical location and name of the Linux kernel. In the Slackware distribution, the kernel is located at /vmlinuz.


/dev/fd0 - first floppy disk drive


/dev/fd0H1440 - driver for the first floppy drive in high density mode. Generally, this is invoked when formatting a floppy drive for a particular density. Slackware comes with drivers that allow for formatting a 3.5" diskette with up to 1.7MB of space. Red Hat and Mandrake do not contain these device driver files by default.


/dev/fd1 - second floppy disk drive


/dev/hda - first IDE hard drive


/dev/hdc - on many machines, the IDE cdrom drive. Most often, there is a symbolic link called /dev/cdrom which is just a link to the true cdrom driver file.


/dev/null
- used when you want to send output into oblivion


/etc/aliases
- file containing aliases used by sendmail and other MTAs (mail transport agents). After updating this file, it is necessary to run the newaliases utility for the changes to be passed to sendmail.


/etc/bashrc - system-wide default functions and aliases for the bash shell


/etc/conf.modules - aliases and options for configurable modules


/etc/crontab - shell script to run different commands periodically (hourly, daily, weekly, monthly, etc.)


/etc/DIR_COLORS - used to store colors for different file types when using ls command. The dircolors command uses this file when there is not a .dir_colors file in the user's home directory. Used in conjunction with the eval command (see below).


/etc/exports
- specifies hosts to which file systems can be exported using NFS. Man exports contains information on how to set up this file for remote users.


/etc/fstab - contains information on partitions and filesystems used by system to mount different partitions and devices on the directory tree


/etc/HOSTNAME - stores the name of the host computer


/etc/hosts - contains a list of host names and absolute IP addresses.


/etc/hosts.allow - hosts allowed (by the tcpd daemon) to access Internet services


/etc/hosts.deny
- hosts forbidden (by the tcpd daemon) to access Internet services


/etc/group - similar to /etc/passwd but for groups


/etc/inetd.conf - configures the inetd daemon to tell it what TCP/IP services to provide (which daemons to load at boot time). A good start to securing a Linux box is to turn off these services unless they are necessary.


/etc/inittab - runs different programs and processes on startup. This is typically the program which is responsible for, among other things, setting the default runlevel, running the rc.sysinit script contained in /etc/rc.d, setting up virtual login terminals, bringing down the system in an orderly fashion in response to[Ctrl][Alt][Del], running the rc script in /etc/rc.d, and running xdm for a graphical login prompt (only if the default runlevel is set for a graphical login).


/etc/issue - pre-login message. This is often overwitten by the /etc/rc.d/rc.S script (in Slackware) or by the /etc/rc.d/rc.local script (in Mandrake and Red Hat, and perhaps other rpm-based distributions). The relevant lines should be commented out (or changed) in these scripts if a custom pre-login message is desired.


/etc/lilo.conf - configuration file for lilo boot loader


/etc/motd - message of the day file, printed immediately after login. This is often overwritten by /etc/rc.d/rc.S (Slackware) or /etc/rc.d/rc.local (Mandrake/Red Hat) on startup. See the remarks in connection with /etc/issue.


/etc/mtab - shows currently mounted devices and partitions and their status


/etc/passwd - contains passwords and other information concerning users who are registered to use the system. For obvious security reasons, this is readable only by root. It can be modified by root directly, but it is preferable to use a configuration utility such as passwd to make the changes. A corrupt /etc/passwd file can easily render a Linux box unusable.


/etc/printcap - shows the setup of printers


/etc/profile - sets system-wide defaults for bash shell. It is this file in Slackware that sets up the DIR_COLORS environment variable for the color ls command. Also sets up other system-wide environment variables.


/etc/resolv.conf - contains a list of domain name servers used by the local machine


/etc/securetty - contains a list of terminals on which root can login. For security reasons, this should not include dialup terminals.


/etc/termcap - ASCII database defining the capabilities and characteristics of different consoles, terminals, and printers


/etc/X11/XF86Config - X configuration file. The location in Slackware is /etc/XF86Config.


/proc/cpuinfo - cpu information


/proc/filesystems - prints filesystems currently in use


/proc/interrupts - prints interrupts currently in use


/proc/ioports - contains a list of the i/o addresses used by various devices connected to the computer


/proc/kcore - The command ls -l /proc/kcore will give the amount of RAM on the computer. It's also possible to use the free command to get the same information (and more).


/proc/version - prints Linux version and other info


/var/log/messages - used by syslog daemon to store kernel boot-time messages


/var/log/lastlog - used by system to store information about last boot

/var/log/wtmp
- contains binary data indicating login times and duration for each user on system


Important Directories:

Different distributions have different directory structures, despite attempts at standardization such as the the Linux Filesystem Hierarchy Standard (FHS) organization.


/bin - essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode

/boot - files used during booting and possibly the kernel itself are stored here

/dev - contains device files for various devices on system

/etc - files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc.

/etc/profile.d - contains scripts that are run by /etc/profile upon login.

/etc/rc.d - contains a number of shell scripts that are run on bootup at different run levels. There is also typically an rc.inet1 script to set up networking (in Slackwar), an rc.modules script to load modular device drivers, and an rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS.

/etc/rc.d/init.d - contains most of the initialization scripts themselves on an rpm-based system.

/etc/rc.d/rc*.d - where ``*'' is a number corresponding to the default run level. Contains files for services to be started and stopped at that run level. On rpm-based systems, these files are symbolic links to the initialization scripts themselves, which are in /etc/rc.d/init.d.

/etc/skel - directory containing several example or skeleton initialization shells. Often contains subdirectories and files used to populate a new user's home directory.

/etc/X11
- configuration files for the X Window system

/home - home directories of individual users


/lib - standard shared library files

/lib/modules - modular device driver files, most with .o extensions

/mnt
- typical mount point for many user-mountable devices such as floppy drives, cd-rom readers, etc. Each device is mounted on a subdirectory of /mnt.

/proc - virtual file system that provides a number of system statistics

/root - home directory for root

/sbin - location of binaries used for system administration, configuration, and monitoring

/tmp
- directory specifically designed for programs and users to store temporary files.

/usr - directory containing a number of subdirectory with programs, libraries, documentation, etc.

/usr/bin - contains most user commands. Should not contain binaries necessary for booting the system, which go in /bin. The /bin directory is generally located on the same disk partition as /, which is mounted in read-only mode during the boot process. Other filesystems are only mounted at a later stage during startup, so putting binaries essential for boot here is not a good idea.

/usr/bin/X11
- most often a symbolic link to /usr/X11R6/bin, which contains executable binaries related to the X Window system

/usr/doc - location of miscellaneous documentation, and the main location of program documentation files under Slackware

/usr/include - standard location of include files used in C programs such as stdio.h

/usr/info - primary location of the GNU info system files

/usr/lib - standard library files such as libc.a. Searched by the linker when programs are compiled.

/usr/lib/X11 - X Window system distribution

/usr/local/bin - yet another place to look for comon executables

/usr/man - location of manual page files

/usr/sbin - other commands used by superuser for system administration

/usr/share - contains subdirectories where many installed programs have configuration, setup and auxiliary files


/usr/share/doc - location of program documentation files under Mandrake and Red Hat


/usr/src - location of source programs used to build system. Source code for programs of all types are often unpacked in this directory.

/usr/src/linux - often a symbolic link to a subdirectory whose name corresponds to the exact version of the Linux kernel that is running. Contains the kernel sources.

/var - administrative files such as log files, used by various utilities

/var/log/packages - contains files, each of which has detailed information on an installed package in Slackware. The same file can also be found at /var/adm/packages, since the adm subdirectory is a symbolic link to log. Each package file contains a short description plus a list of all installed files.

/var/log/scripts - package installation scripts in Slackware are stored here. You can inspect these scripts to see what special features are included in individual packages.


/var/spool - temporary storage for files being printed, mail that has not yet been picked up, etc.

Important Bash Shell Variables

These variables are most often inherited or declared when a shell is started. A great reference for bash shell variable, bash builtin commands, and bash in general is SSC (2000).


HOME - home directory, abbreviated as ~


MAIL - name of file that mail is stored in (mailbox)


MAILCHECK - sets the frequency at which bash checks for mail


PATH - directory paths to search for executable files. According to A Practical Guide to Linux, p.329, the PATH is set in /etc/profile. On my Linux box, /etc/profile adds /usr/X11R6/bin to the path, which means that the path must be set before by another configuration file. The .bash_profile file in my home directory adds /home/ambler/bin to the path. On my Linux box, the first command to set the path would seem to be in /etc/rc.d/rc.sysinit, which is one of the shell scripts invoked by the init process (inittab). Then, /etc/profile adds /usr/X11R6/bin. Finally, .bash_profile adds /home/ambler/bin.


PS1 - prompt string. Things that can be put in the prompt string include \h (hostname), \u (username), \w (absolute pathname of working directory), \W (name of working directory w/o path), \d (date), \t (time). See p.331 of A Practical Guide to Linux for more details. On my Red Hat boxes, the primary prompt string is set in the /etc/bashrc file. The prompt is also set in /etc/profile, but the setting in bashrc seems to take precedence. I also have a .bashrc file, which in turn runs /etc/bashrc, which sets the prompt. This means that the same prompt is used by xterm and rxvt in X sessions. On my Slackware box, the command line prompt is set in /etc/profile. The xterm and rxvt prompts are different, since I don't have a .bash_profile file which is run when an xterm is started. In fact, I don't know where the prompt is set in X sessions. It is not set by /usr/X11R6/lib/X11/app-defaults/XTerm.


PS2 - secondary prompt string.

0 comments:

Post a Comment