Thursday, 14 June 2012

Basic Commands


External Link: SS64  oreillynet

man - format and display the on-line manual page
            Usage : man date

help - Display help for a built-in command
 
            Usage : date --help

info - information about the command 
 
            info date
ls lists the content of directory
ls
ls -l       list the files with all information
ls –a     list files including hidden files
ls –la    long list with hidden files



cd Change Directory
cd  /home/user/
Absolute bath /home  (absolute path: Relating to file systems, the location of a directory or file that can be accessed regardless of the current working location of a user)          
eg  /home/user/mypicture.jpg
Relative path The relative pathnames are opposite to absolute pathname. A reative pathname does not begin with a slash ( / ). Generally you specifies location relative to your current working directory.
eg  cd home/user/myfile.jpg,
cd ..  goes one directory back
cd - return to the last directory
cd ~ go to the current user's home directory


mkdir  Create one or more directories
mkdir folder1 folder2
mkdir -p work/junk/questions  (mkdir -p Create intervening parent directories if they don't exist)


pwd  Print the full pathname of the current working directory. See also the dirs shell command built intobash.
pwd


cp  Copy files/directories
cp file1 file2
cp –vrf dirA dirB


echo  display a line of text           
echo "hello world"   (displays hello world in command line)


mv move files to another location or rename files
mv  /home/user/myfile /home/Admin/myfile
mv myfile your file


rm remove files/directories
rm myfile
rm -rf mydirectory  (rmdir remove directory)


find  search for files in a directory hierarchy, an extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. The default pathname is the current directory. The most useful conditions include -name and -type (for general use), -exec and -size (for advanced use), and -mtime and -user
find /home -name myfile


history shows the history of commands
            -c   Clear the history list
!             Start a history substitution, except when followed by a space
!n            Refer to command line n.
!-n           Run the command n lines back.
!!            Run the previous command.




mount mount a file structure. The file structure on device is mounted ondirectory. If no device is specified, mount looks for an entry in /etc/fstab to find out what device is associated with the given directory. 
mount /dev/sdb1 /media
mount -t   to limit this to all filesystems of a particular type.




umount allos to unmount the mounted filesystems 
umount /dev/sdb1          or umount /media


fdisk  Linux command line disk partitioning tool

Touch  to create empty file or updating the date and time to the current time


Date    shows the date and time


cal       shows the calendar


du         Estimate file space usage


df           shows the disk free 


diff      Display the differences between two files

clear  Clear terminal screen
 
dd        Convert and copy a file, write disk headers, boot records, create a boot floppy. dd can make an exact clone of an (unmounted) disk, this will include all blank space so the output destination must be at least as large as the input.
dd if=linux_cd_image.iso of=/dev/sdb

tar
tar  was initially developed to write data to sequential I/O devices for tape backup purposes. It is now commonly used to collect many files into one larger file for distribution orarchiving, while preserving file system information such as user and group permissions, dates, and directory structures
tar -cvf mytarball.tar file1 file2 file3
tar -xvf mytarball.tar
System states
shutdown              init 0, poweroff
reboot                  init 6, reboot
Sleep                   echo mem > /sys/power/state
Hibernation          echo disk > /sys/power/state  

No comments:

Post a Comment