Wednesday, 29 January 2014

Linux simple Command

Command
Usage
Alias
To create the shortcut for the Command
To go the path /root/user/test 
 Linux command is  cd  /root/user/test  .
alias   alias_name  = ’ cd /root/user/test’
We can use alias_name  as command to go mentioned path

bc
To Perform the simple mathematical operation in terminal itself
bzip2
Compress the files .
Bzip2  -c -9  old_file_name.mp3> new_file_name.bz.2.
-c—standard output.
-9 for best compression result
Cat
used for the create , view , concatenate the file
Cat > testFile.txt – To create the new file.
Cat testFile.txt   - To view the testFile.txt.
Cat >>testFile.txt to append data in testFile1.txt file
Cat testFile.txt testFile2.txt >output.txt
Chmod
To change  the file rights
Chmod     user group other;

                0             none
               1             execute only
               2             write only
               3             write and execute
               4             read only
               5             read and execute
               6             read and write
               7             set all permissions
chmod  700—all rights for user . none of rights for group and others.
Chmod  600 – only read and write for user  rest of no rights.
6=read+write =4+2=6;

Copy
Cp  file1.txt  file 2.txt – To copy the content file1 to file2
Cp –r  folder1  folder2   used to copy folder and subfolder
scp- copy in remote system 

Crontab
command used to add jobs in cron.jobs calls itself
chrontab –e * * * * *  jobname;
1st * -- minute
2nd * – hour
3rd  *– day
4th * -  month
5th *-  weak
Grep
to search the word in file.
grep  searchwordfilename;
It will show the searched word in terminal.
grep searchwordfilename>newFile.txt
It will create a new file contains the searched word
   

Halt
shutdown the system

head
To view the content of file.
Head  filename ---- show the first 10 lines
Head -45 filename --show the first 45 lines
Head -5 filename>test.txt
  -First 5 lines of filename will copied to test.txt file.


Paste
Paste the content
Paste file1.txt file2.txt  -- to paste the file1.txt content to file2.txt

Pwd
Path of current working directory.
link
This command is used to link the file. We cannot link already present file.
Link test1.txt test2.txt .
If we change the test1.txt  it will reflect  in  test2.txt file also.
tail
Like head command.
To view the content of file.
tail filename ---- show the last 10 lines
tail -45 filename --show the last 45 lines
tail -5 filename>test.txt
  -First 5 lines of filename will copy to test.txt file.

man
It is used to know about command
Man cp—To know about the copy command
ls
List out the list of files


VI Editor commands
http://www.cs.rit.edu/~cslab/vi.html

Mount Windows shared folder in Linux machine at LAN connection
This for Temporary mount
Step 1: Create the folder  at Linux machine .
Step 2: Share your windows folder in Network
Step 2: Execute following command
mount -t cifs //windows IP/windows sharefolder name -o
windowsUsername=<USERNAME>,password=<PASSWORD> Linux folder created path



mount -t cifs //192.168.2.196/MyFile -o username=admin,password=123 /root/Desktop/MyFile


For Permanent Mount:

By using vi editor open the fstab under etc.

vi /etc/fstab 

And add the following code 

//windows IP/windowsSharefolderName  LinuxFolderCreatedPathFile FilesystemName  permission windowsUsername=<USERNAME> ,password=<PASSWORD>

 //192.168.2.196/MyFile   /root/Desktop/MyFile cifs  rw  username=admin,password=123

online Linux command practice

http://bellard.org/jslinux/




No comments:

Post a Comment