Review of Frequently used UNIX Commands

REVIEW OF FREQUENTLY USED UNIX COMMANDS

GENERAL COMMAND SYNTAX:

$ command –[options] <arguments>

DISPLAYING CONTENTS OF A DIRECTORY:

$ ls      (simple form)

$ ls –l   (long form)

$ ls –la  [long form and all files including hidden files. (hidden filenames begin with a dot)]

DISPLAYING FILENAMES THAT HAVE COMMON START/END:

$ ls –l chapter*  (shows filenames like chapter01, chapter02, chapterfour, etc)

$ ls –l *.txt     (shows filenames like book.txt, song.txt, readme.txt, etc)

DISPLAYING CONTENTS OF ONE OR MORE FILES:

$ cat song.txt

$ cat song.txt book.txt readme.txt

COPYING/MOVING/RENAMING FILES:

$ cp file1.txt file2.txt  (copies! file1.txt also exists)

$ mv file1.txt file2.txt  (renames! file1.txt NO longer exists)

$ mv file1.txt docs/year2005/file1.txt  (moves! from current directory to docs/year2005 directory)

$ mv file1.txt docs/year2005/file2.txt  (moves and renames! from current directory to docs/year2005 directory)

CREATING DIRECTORIES:

$ mkdir year2005 year2006
$ mkdir year2005/docs year2005/pics

CREATING/MODIFYING FILES USING pico EDITOR:

$ pico year2005/docs/myfile.txt

            pathname

            type in

press Ctrl + X to EXIT

DELETING FILES/DIRECTORIES:

$ rm year2005/docs/myfile.txt      (deletes myfile.txt)

$ rm song.txt book.txt readme.txt  (deletes song.txt and readme.txt)

$ rmdir year2006     (deletes the empty directory year2006)

$ rm -r year2005     (deletes the non-empty directory year2005)

CHANGING FILE PERMISSIONS:
Users:
    a-all
    u-owner
    g-group
    o-others

Permissions:
    r-read
    w-write
    x-execute

$ chmod a+x hello2     (gives all users execute permission for the file hello2)

$ chmod go-w hwk1.txt  (removes write permission from group and other users for the file hwk1.txt)

$ chmod g+rw song.txt  (gives read and write permissions to group users for the file song.txt)

Kaynak: sct.emu.edu.tr
belgesi-1156

Belgeci , 2422 belge yazmış

Cevap Gönderin