Oct 26, 2010

Linux Basics to remind always.


What is Open Source ? Open source: software and source code available to all. The freedom to distribute software and source code The ability to modify and create derived works Integrity of author's code.
Linux Principles :- 
Everything is a file (including hardware)
● Small, single-purpose programs.
● Ability to chain programs together to perform complex tasks.
● Avoid captive user interfaces.
● Configuration data stored in text.
Linux Usage Basics
Basically there are two types of login screens :- virtual consoles(text-based) and graphical logins (called displaymanagers)
● Login using login name and password.
● Each user has a home directory for personal file storage.
 
In linux system runs on six virtual consoles and one graphical console 
Switch among virtual consoles by typing:Ctrl-Alt-F[1-6]
Access the graphical console by typing Ctrl-Alt-F7
●Server systems often have only virtual consoles.
●Desktops and workstations typically have both.
Starting of X server
● On some systems, the X server starts automatically at boot time.
● Otherwise, if systems come up in virtual consoles, users must start the X server manually.
The X server must be pre-configured by the system administrator.
Log into a virtual console and run startx.
The X server appears on Ctrl-Alt-F7.
After logging how can you change your password
● Passwords control access to the system
Change the password the first time you log in
Change it regularly thereafter.Select a password that is hard to guess
● To change your password using GNOME, navigate to System->Preferences->About Me
and then click Password.
● To change your password from a terminal: passwd 
The root user :-
The root user: a special administrative account also called the superuser and root has near complete control over the system.Do not login as root unless necessary. 
Change the Identities :-
● su - creates new shell as root
● sudo command runs command as root (Requires prior configuration by systemadministrator)
● id shows information on the current user.
Text Files Editors :-
The nano editor (Easy to learn, easy to use)Not as feature-packed as some advanced editors
Other editors:gedit, a simple graphical editor
vim, an advanced, full feature editor
gvim, a graphical version of the vim editor
Some Simple Commands :-
● date - display date and time.
● cal - display calendar.
●whatis - Displays short descriptions of commands.
●man and info - Provides documentation for commands.
man -k (keyword lists all matching pages) info (info pages are structured like a web site)
Browsing the FileSystem :-
● Files and directories are organized into a single-rooted inverted tree structure.
● Filesystem begins at the root directory, represented by a lone / (forward slash) character.
● Names are case-sensitive.
● Paths are delimited by /.
Some Important Directories :-
● Home Directories: /root,/home/username
● User Executables: /bin, /usr/bin, /usr/local/bin
● System Executables: /sbin, /usr/sbin, /usr/local/sbin
● Other Mountpoints: /media, /mnt
● Configuration: /etc
● Temporary Files: /tmp
● Kernels and Bootloader: /boot
● Server Data: /var, /srv
● System Information: /proc, /sys
● Shared Libraries: /lib, /usr/lib, /usr/local/lib
File and Directory Names
●Names may be up to 255 characters
●All characters are valid, except the forwardslash
It may be unwise to use certain special characters in file or directory names
Some characters should be protected with quotes when referencing them
● Names are case-sensitive
Example: MAIL, Mail, mail, and mAiL Again, possible, but may not be wise
Changing Directories
cd changes directories
To an absolute or relative path:
■ cd /home/joshua/work
■ cd project/docs
To a directory one level up:
■ cd ..
To your home directory:
■ cd
To your previous working directory:
Listing Directory Contents
● Lists the contents of the current directory or a specified directory
● Usage:
ls [options] [files_or_dirs] Here below some Examples
ls -a (include hidden files)
ls -l (display extra information)
ls -R (recurse through directories)
ls -ld (directory and symlink information)
Copying Files and Directories
● cp [options] file destination
● More than one file may be copied at a time if the destination is a directory:
cp [options] file1 file2 dest
Moving and Renaming Files and Directories
● mv - move and/or rename files and directories
● Usage: mv [options] file destination
● More than one file may be moved at a time if the destination is a directory:
mv [options] file1 file2 destination
● Destination works like cp
Creating and Removing Directories
● mkdir creates directories
● rmdir removes empty directories
● rm -r recursively removes directory trees
Creating and Removing Files
● touch - create empty files or update file timestamps
● rm - remove files
● Usage: rm [options] ...
● Example:
rm -i file (interactive)
rm -r directory (recursive)
rm -f file (force)