Monday, 24 November 2014

The dmesg Command

The dmesg Command




The dmesg  command s used to write the kernel messages in Linux 
A kernel is the core of an operating system. It is the first part of the OS that is loaded into memory when a computer bootup (i.e., starts up), and it controls virtually everything on a system. The numerous messages generated by the kernel that appear on the display screen as a computer boots up show the hardware devices that the kernel detects and indicate whether it is able to configure them.
dmesg obtains its data by reading the kernel ring buffer. A buffer is a portion of a computer's memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a hard drive disk (HDD), printer or keyboard. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it. dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system. Its basic syntax is
dmesg [options]
Invoking dmesg without any of its options(which are rarely used) causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe, thereby allowing the startup messages to be viewed one screenful at a time:
dmesg | less
less allows the output to be moved forward one screenful at a time by pressing the SPACE bar, backward by pressing the b key and removed by pressing the q key. (The more command could have been used here instead of the less command; however, less is newer than more and has additional functions, including the ability to return to previous pages of the output.)
When a user encounters a problem with the system, it can be convenient to write the output of dmesg to a file and then send that file by e-mail to a system administrator or other knowledgeable person for assistance. For example, the output could be redirected to a file named boot_messages using the output redirection operator (designated by a rightward facing angle bracket) as follows:
dmesg > boot_messages
Because of the length of the output of dmesg, it can be convenient to pipe its output to grep, a filter which searches for any lines that contain the string (i.e., sequence of characters) following it. The -i option can be used to tell grep to ignore the case (i.e., lower case or upper case) of the letters in the string. For example, the following command lists all references to USB(universal serial bus) devices in the kernel messages:
dmesg | grep -i usb
And the following tells dmesg to show all serial ports (which are represented by the string tty):
dmesg | grep -i tty
The dmesg and grep combination can also be used to show how much physical memory (i.e., RAM) is available on the system:
dmesg | grep -i memory
The following command checks to confirm that the HDD(s) is running in DMA (direct memory access) mode:
dmesg | grep -i dma
The output of dmesg is maintained in the log file /var/log/dmesg, and it can thus also be easily viewed by reading that file with a text editor, such as vi or gedit, or with a command such as cat, e.g.,
cat /var/log/dmesg | less

Monday, 8 September 2014

To install Local yum server or yum client on Centos 6 & Centos 7 ( Also Redhat 6 )



To install Local yum server or yum client  on Centos 6 & Centos 7 ( Also in Redhat 6 ) 


We are using 2 system , 1 for server & 2 for client system.

Yum Server OS               : Centos 6.4 & 7           
Yum Server IP Address   : 192.168.1.2
Client OS                       : Centos 6.4 & 7
Client IP Address           :  192.168.1.3

SERVER SIDE :- 192.168.1.2

Insert Your Centos DVD in server CD/DVD rom .

# mount /dev/cdrom /mnt/
# cd /mnt/
# cd Packages/
# rpm -ivh vsftpd-2.2.2-11.el6_3.1.i686.rpm

  warning: vsftpd-2.2.2-11.el6_3.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID
  c105b9de: NOKEY
  Preparing...               ########################################### [100%]
  1:vsftpd                    ########################################### [100%]

# service vsftpd restart
# chkconfig vsftpd on
# rpm -ivh libxml2-python-2.7.6-8.el6_3.4.i686.rpm
# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm
# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
# rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
# mkdir /var/ftp/pub/Packages
# cp -ar /mnt/Packages/*.* /var/ftp/pub/Packages

{note :- remove or rename to all older repositories } 

# vi /etc/yum.repos.d/yum.repo
     
      [YumServer]
      name=Packages
      baseurl=file:///var/ftp/pub/Packages               (note:- We are using '///' in server )
      gpgcheck=0

      enabled=1

      :wq

# setsebool -P ftp_home_dir on
# vi /etc/sysconfig/iptables
      [...]
      -A INPUT -p udp -m state --state NEW --dport 21 -j ACCEPT
      -A INPUT -p tcp -m state --state NEW --dport 21 -j ACCEPT
      [...]

      :wq

# createrepo -v /var/ftp/pub/Packages



# yum clean all
# yum update

CLIENT SIDE :- 192.168.1.3

# vi /etc/yum.repos.d/yum.repo
      [YumServer]
      name=Packages
      baseurl=ftp://192.168.1.2/pub/Packages               (note:- We are using '//' in client )
      gpgcheck=0

      enabled=1

      :wq

# yum update



enjoy your yum server ......


Friday, 5 September 2014

Backup through script on Centos, Redhat, Fedora ( Any flavor of Linux )


Backup through script on Centos, Redhat, Fedora ( Any flavor of Linux  )

Through this script , we can take backup of file , folder , any drive etc 

Create a folder to take backup . For Example :-

$mkdir ~/backup/
$cd  /usr/local/bin/
$vi backup.sh
***********************************************************************************
***********************************************************************************
         #!/bin/bash
         # A script for backing up any file & folder
         # First argument : The directory to be backed up
         # Second argument : The location to back-up to.
                        ORIG=$1
                        BACK=~/backups/

          if [ -e $BACK ]
          then
                        echo "WARNING:$BACK exists"
                        read -p "Press Ctrl+c to exit or Enter to Proceed:"
          fi
          cp -av $ORIG $BACK
          echo "Backup of $ORIG to $BACK completed at:$(date)"


       :wq
************************************************************************************
************************************************************************************
$ chmod 755 backup.sh
$ backup  (Path of file & folder Only )
$ cd  ~/backup/
$ ls -l                                             


*********************************************************************************
**************************************Enjoy *************************************
*********************************************************************************

Wednesday, 3 September 2014

To Capture your own Desktop video & audio for Blog or youtube on Ubuntu 13.04.






To Capture your own Desktop video & audio for Blog or youtube on Ubuntu 13.04. 


In ubuntu 13.04 open "Ubuntu Software center " & search "RecordMyDesktop" . Install this software on ubuntu 13.04 .You can record audio & video both for Blog & YouTube. See all screen shot step by step .









Video to Capture or Play Same background Music


                                                     


In Last Screenshot you check your saved video location or path .Also click given link to see video. how to record .

https://www.youtube.com/watch?v=9jMQK4_qjEQ&feature=youtu.be






Enjoy .....


Tuesday, 2 September 2014

Samba server installation step by step on CentOS 6.x or redhat 6.x


Samba server installation step by step on CentOS 6.x  or redhat 6.x.

Samba is a client/server system that implements network resource sharing for Linux & Windows computers. Through Samba server Printer can be shared linux & windows machine.



To install the samba package,enter the following command:

# yum install samba samba-client samba-common

Check the version of installed samba software by using this command:


# smbd --version
  Version 3.6.9-167.el6_5

Configure the samba service, so that, it will start automatically at boot time:


# chkconfig smb on
# chkconfig nmb on

Add these Iptables rules, so that samba will work perfectly:


# iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# service iptables save


Backup the smb.conf file, then delete it and create the new one:


# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# rm /etc/samba/smb.conf
# touch /etc/samba/smb.conf
# vi /etc/samba/smb.conf

Add these lines,in your smb.conf file (or change it according to your requirement):

#======================= Global Settings =====================================

[global]

workgroup = WORKGROUP

security = share

map to guest = bad user

#============================ Share Definitions ==============================

[MyShare]

path = /home/samba/share

browsable =yes

writable = yes

guest ok = yes

read only = no

:wq

# service smb restart
# service nmb restart

Change permission for samba share:


# chmod -R 0777 /home/samba/share


Access the samba share from windows(where 192.168.1.15 address of my samba server):






Add and manage Samba users and groups

Add a group in your CentOS server:

# useradd smbuser
# groupadd smbgrp
# usermod -a -G smbgrp smbuser
# smbpasswd -a smbuser

Create a new share, set the permission on the share:

# cd /home/samba/
# mkdir secure
# chown -R arbab:smbgrp secure/
# chmod -R 0770 secure/
# vi /etc/samba/smb.conf

*******Add the newly created samba share in smb.conf file:**********

[Secure]

path = /home/samba/secure

valid users = @smbgrp

guest ok = no

writable = yes

browsable = yes

:wq

# service smb restart
# service nmb restart

Check the syntax error with testparm:


# testparm
Testing from Windows Machine:




Crontab Examples on Linux { Centos ,Redhat, Fedora, ....etc }


Crontab Examples on Linux { Centos ,Redhat, Fedora, ....etc }

Using cron you can execute a shell-script or Linux commands at a
specific time and date. For example a sysadmin can schedule a backup
job that can run every day.

How to add a job to the cron?

# crontab –e

0 5 * * * /root/bin/backup.sh

This will execute /root/bin/backup.sh at 5 a.m every day.

Description of Cron fields

Following is the format of the crontab file.

{minute} {hour} {day-of-month} {month} {day-of-week}
{full-path-to-shell-script}

• minute:              Allowed range   0 – 59
• hour:                 Allowed range   0 – 23

• day-of-month:    Allowed range   0 – 31
• month:              Allowed range   1 – 12.    1 = January. 12 = December.
• Day-of-week:    Allowed range     0 – 7.    Sunday is either 0 or 7.

Crontab examples

1. Run at 12:01 a.m. 1 minute after midnight everyday. This is a good
time to run backup when the system is not under load.

      1 0 * * * /root/bin/backup.sh

2. Run backup every weekday (Mon – Fri) at 11:59 p.m.

      59 11 * * 1,2,3,4,5 /root/bin/backup.sh

Following will also do the same.

     59 11 * * 1-5 /root/bin/backup.sh

3. Execute the command every 5 minutes.

     */5 * * * * /root/bin/check-status.sh

4. Execute at 1:10 p.m on 1st of every month

     10 13 1 * * /root/bin/full-backup.sh

5. Execute 11 p.m on weekdays.

     0 23 * * 1-5 /root/bin/incremental-backup.sh


Crontab Options
The following are the available options with crontab:

• crontab –e : Edit the crontab file. This will create a crontab, if it
  doesn’t exist
• crontab –l : Display the crontab file.
• crontab -r : Remove the crontab file.
• crontab -ir : This will prompt user before deleting a crontab.


Sunday, 31 August 2014

To install FTP Server step by step on CentOS 6.x or Redhat 6.x

To install FTP Server step by step on CentOS 6.x or REDHAT 6.x 

FTP server is used to transfer files between server and clients. All major operating system supports ftp. FTP is the most used protocol over internet to transfer files. Like most Internet operations, FTP works on a client/ server model. FTP client programs can enable users to transfer files to and from a remote system running an FTP server program.

In this blog you learn, To install & Configure FTP server Step by Step on Centos 6.X or Redhat 6.X .  
 Now , install some package on Centos 6.X

# yum install vsftpd*  



Than run command 
# getsebool -a | grep ftp
# setsebool -P  ftp_home_dir on



Now,  Edit /etc/vsftpd/vsftpd.conf file . Uncomment and edit the bold line .
# vi /etc/vsftpd/vsftpd.conf

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to centos FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
use_localtime=YES


:wq

Now, Create User on  Ftp server .
# useradd ravi
# passwd ravi



Now, Add this user on /etc/vsftpd/userlist.
# vi /etc/vsftpd/userlist



 # service vsftpd restart 
 # chkconfig vsftpd on



Now , Open Browser type ftp://IPftpServer , username or password .
ftp://192.168.1.5



You can also try through FileZilla .

Type HOSTIP , User Name , Password , Port no 21 .




Enjoy your FTP server .......

Saturday, 30 August 2014

Difference between Ext2, Ext3 & Ext4 file systems.

Difference between Ext2, Ext3 & Ext4 file systems 


Linux is a very flexible operating system that has a long history of interoperability with other systems on a different hardware platforms,linux can read and write several different file systems that originated with other operating systems much different from linux.
One main reason that linux supports so many file systems because linux work on VFS (Virtual file system )layer that is a data abstraction layer between the kernal and the programs in userspace that issue file system commands.”Programs that run inside the kernal are in kernelspace,programs that don’t run inside the kernel called in userspace”.The VFS layer avoids duplication of common code between all file systems also it provides a fairly universal backward compatible method for programs to access data from almost all type of file systems.

Differences between Ext2, Ext3 & Ext4 file systems in linux.

Ext2   

It was the standard file system for linux until the introduction of ext3. It was introduced with the 1.0 kernel in 1993. It is flexible,can handle file system up to 4 TB,and supports long filenames up to 1012 characters. It has sparse super blocks feature which increase file system performance.In case any user processes fill up a file system,ext2 normally reserves about 5% of disk blocks for exclusive use by root so that root can easily recover from that situation.Now our rescue diskettes use ext2 instead of minix.
Ext3 

It provides all the features of ext2,and also features journaling and backward compatibility with ext2.The backward compatibility enables you to still run kernals that are only ext2-aware with ext3 partitions.we can also use all of the ext2 file system tuning,repair and recovery tools with ext3 also you can upgrade an ext2 file system to an ext3 file system without losing any of your data.
Ext3′s journaling feature speeds up the amount of time it takes to bring the file system back to a sane state if it’s not been cleanly unmounted (that is,in the event of a power outage or a system crash). Under ext2,when a file system is uncleanly mounted ,the whole file system must be checked.This takes a long time on large file systems.On an ext3 system ,the system keeps a record of uncommitted file transactions and applies only those transactions when the system is brought back up.So a complete system check is not required and the system will come back up much faster.
A cleanly unmounted ext3 file system can be mounted and used as an ext2 file system,this capability can come in handy if you need to revert back to an older kernel that is not aware of ext3.The kernel sees the ext3 filesystem as an ext2 file system.



Ext4  

It is part of the Linux 2.6.28 kernel, Ext4 is the evolution of the most used Linux file system, Ext3. In many ways, Ext4 is a deeper improvement over Ext3 than Ext3 was over Ext2 . Ext3 was mostly about adding journaling to Ext2, but Ext4 modifies important data structures of the file system such as the ones destined to store the file data. The result is a filesystem with an improved design, better performance, reliability and features.
Features of Ext4 file system : 
1. Compatibility
2. Bigger filesystem/file sizes
3. Subdirectory scalability
4. Extents
5. Multiblock allocation
6. Delayed allocation
7. Fast fsck
8. Journal checksumming
9. Online defragmentation
10. Inode-related features
11. Persistent preallocation
12. Barriers on by default




Linux Boot Process


Linux Boot Process


6 Stages of Linux Boot Process (Startup Sequence)

Press the power button on your system, and after few moments you see the Linux login prompt.
Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login prompt appears?

The following are the 6 high level stages of a typical Linux boot process.



1. BIOS

  • BIOS stands for Basic Input/Output System
  • Performs some system integrity checks
  • Searches, loads, and executes the boot loader program.
  • It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.
  • Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
  • So, in simple terms BIOS loads and executes the MBR boot loader.

2. MBR

  • MBR stands for Master Boot Record.
  • It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
  • MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
  • It contains information about GRUB (or LILO in old systems).
  • So, in simple terms MBR loads and executes the GRUB boot loader.

3. GRUB

  • GRUB stands for Grand Unified Bootloader.
  • If you have multiple kernel images installed on your system, you can choose which one to be executed.
  • GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
  • GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
  • Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS.
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
          initrd /boot/initrd-2.6.18-194.el5PAE.img
  • As you notice from the above info, it contains kernel and initrd image.
  • So, in simple terms GRUB just loads and executes Kernel and initrd images.

4. Kernel

  • Mounts the root file system as specified in the “root=” in grub.conf
  • Kernel executes the /sbin/init program
  • Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
  • initrd stands for Initial RAM Disk.
  • initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

5. Init

  • Looks at the /etc/inittab file to decide the Linux run level.
  • Following are the available run levels
    • 0 – halt
    • 1 – Single user mode
    • 2 – Multiuser, without NFS
    • 3 – Full multiuser mode
    • 4 – unused
    • 5 – X11
    • 6 – reboot
  • Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
  • Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
  • If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.
  • Typically you would set the default run level to either 3 or 5.

6. Runlevel programs

  • When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.
  • Depending on your default init level setting, the system will execute the programs from one of the following directories.
    • Run level 0 – /etc/rc.d/rc0.d/
    • Run level 1 – /etc/rc.d/rc1.d/
    • Run level 2 – /etc/rc.d/rc2.d/
    • Run level 3 – /etc/rc.d/rc3.d/
    • Run level 4 – /etc/rc.d/rc4.d/
    • Run level 5 – /etc/rc.d/rc5.d/
    • Run level 6 – /etc/rc.d/rc6.d/
  • Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
  • Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
  • Programs starts with S are used during startup. S for startup.
  • Programs starts with K are used during shutdown. K for kill.
  • There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
  • For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.
There you have it. That is what happens during the Linux boot process.




Basic Linux Commands


Basic Linux Commands


Command  Example                     Description
catSends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.
 cat .bashrcSends the contents of the ".bashrc" file to the screen.

cd
Change directory
cd /homeChange the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home".
cd httpdChange the current working directory to httpd, relative to the current location which is "/home". The full path of the new working directory is "/home/httpd".
cd ..Move to the parent directory of the current directory. This command will make the current working directory "/home.
cd ~Move to the user's home directory which is "/home/username". The '~' indicates the users home directory.
cpCopy files
cp myfile yourfileCopy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists.
cp -i myfile yourfileWith the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten.
cp -i /data/myfile .Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file.
cp -dpr srcdir destdirCopy all files from the directory "srcdir" to the directory "destdir" preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.

dd

dd if=/dev/hdb1 of=/backup/

Disk duplicate.
The man page says this command is to "Convert and copy a file", but although used by more advanced users, it can be a very handy command. The "if" means input file, "of" means output file.

df

Show the amount of disk space used on each mounted filesystem.

less


less textfile


Similar to the more command, but the user can page up and down through the file. The example displays the contents of textfile.

ln

Creates a symbolic link to a file.
ln -s test symlinkCreates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test.

locate

A fast database driven file locator.
slocate -uThis command builds the slocate database. It will take several minutes to complete this command. This command must be used before searching for files, however cron runs this command periodically on most systems.
locate whereisLists all files whose names contain the string "whereis".



lsList files
lsList files in the current working directory except those starting with . and only show the file name.
ls -alList all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp


more


Allows file contents or piped output to be sent to the screen one page at a time.
more /etc/profileLists the contents of the "/etc/profile" file to the screen one page at a time.
ls -al |morePerforms a directory listing of all files and pipes the output of the listing through more. If the directory listing is longer than a page, it will be listed one page at a time.


mv


Move or rename files
mv -i myfile yourfileMove the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile".
mv -i /data/myfile .Move the file from "myfile" from the directory "/data" to the current working directory.


pwd


Show the name of the current working directory
more /etc/profileLists the contents of the "/etc/profile" file to the screen one page at a time.

shutdown

Shuts the system down.
shutdown -h nowShuts the system down to halt immediately.
shutdown -r nowShuts the system down immediately and the system reboots.

whereis

Show where the binary, source and manual page files are for a command



clear
dmesg
whereis lsLocates binaries and manual pages for the ls command.


Clears the terminal screen.
Prints the messages resulting from the most recent system boot.

Lots of Flavours of Linux

Lots of Flavours of Linux












                                                                                                                     




                                                                                                                          linuxtechman......