linux cammand

Upload: mohit-gupta

Post on 04-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Linux Cammand

    1/3

    open pdf file:- evince mohit.pdf

    replace,undo,redo,su,chmod, ./, >,sed

    replace cammand:-:13,37s/moh/mohit/g :-to replace the moh to mohit from line 73 to line 37.:1,$s/moh/mohit/g :-to rplace the moh to mohit from line 1 to last line of the file.

    undo:- uredo:- ctrl+r

    su(switch user): su cammand use for switch the user (eg:- su mohit, after this system ask thepassword, after entering the password user will change)

    chmod(change mode):- use for changing the mode of file or directory eg:chmod 764filename

    here sets read, write and execution access for the owner

    and read and write and no execution for group,and read, no write, no execute for others

    To view the current file mode:$ ls -l ''file''To view the all file mode:$ ls -ltr

    r read read a file or list a directory's contentsw write write to a file or directoryx execute execute a file or recurse a directory tree# Permission4 read only2 write only

    1 execute only0 none

    7(1+2+4) full6(4+2) read and write5(4+1) read and execute4 read only3(2+1) write and execute2 write only1 execute only0 none

    Operator Description

    + adds the specified modes to the specified classes- removes the specified modes from the specified classes= the modes specified are to be made the exact modes for the specified classes

    Command line examples:command explanationchmod a+r file read is added for allchmod a-x file execute permission is removed for all

  • 7/30/2019 Linux Cammand

    2/3

    chmod a+rw file change the permissions of the file file to read and writefor all.chmod +rwx file On some UNIX platforms such as BSD, this will restore thepermission

    of the file file to default: -rwxr-xr-x.chmod u=rw,go= file read and write is set for the owner, all permissions arecleared for

    the group and otherschmod -R u+w,go-w docs change the permissions of the directory docs and all itscontents to

    add write access for the user, and deny write access foreverybody

    else.chmod file removes all privileges for allchmod 777 file change the permissions of the file file to read, write, and execute

    for all.chmod 4755 file the 4 specifies set user ID and the rest is equivalent tou=rwx (4+2+1),

    go=rx (4+1 & 4+1).chmod -R u+rwX,g-rwx,o-rwx directory set a directory tree to rwx for owner directories,

    rw for owner files, --- for group andothers.

    chmod -R a-x+X directory remove the execute permission on allfiles in adirectory tree, while allowing for dir

    ectory browsing.

    ./ means- if a path is /home/mohit/test1/test2/ and we are in mohit dicrectory than no need write

    whole path just ./test1/test so ./ is consider as /home/mohit

    > file_name:- standard output text,write into the file_name.ls > mohit.txt in this except the standard out it write the all f

    older or file into

    mohit.txt file

    sed :-(stream editor) You can use the sed command to change all occurrences of one string to another

    within a file, just like the search-and-replace feature of your word processor. The sed command

    can also delete a range of lines from a fileeg:- 1 replace-> sed 's/oldstring/newstring/g'

    i.e. sed 's/lamb$/ham/g' mohit.txt2 Deletion-> sed ',d'

    i.e. sed '2,3d' mohit.txtnote:- Since sed is a stream editor, it takes the file given as input, and

    sends the output to

    the screen, unless you redirect output to a file. In other words, sed does not change

    the input file.To change and save the results in a new file, enter this:

    sed 'oldstring/newstring/g' mohit.txt > new.file

    Extract tr.gz. file :-To extract one or more members from an archive, enter:

  • 7/30/2019 Linux Cammand

    3/3