1 / 17

Basic Unix Commands

Basic Unix Commands. Listing files and directories. ls :command is used to list the files and directories in present working directory ls command is most used command syntax: ls Lists the files and directories in present working directory. ls. Display One File Per Line Using ls -a

lulu
Télécharger la présentation

Basic Unix Commands

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Unix Commands

  2. Listing files and directories ls:command is used to list the files and directories in present working directory ls command is most used command syntax: ls Lists the files and directories in present working directory

  3. ls Display One File Per Line Using ls -a To show hidden files means . Files in unix

  4. ls Display All Information About Files/Directories Usingls -l To show long listing information about the file/directory. $ ls -l -rw-r----- 1 srinivas team-dev 9275204 Jun 13 15:27 mthesaur.txt.gz 1st Character – File Type: - normal file d directory

  5. ls Field 1 – File Permissions Field 2 – Number of links Field 3 – Owner Field 4 – Group Field 5 – Size Field 6 – Last modified date & time Field 7 – File name

  6. Display File Size in Human Readable Format Using ls -lh Use ls -lh (h stands for human readable form), to display file size in easy to read format. i.e M for MB, K for KB, G for GB. $ls -lh -rw-r----- 1 srinivas team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz

  7. cd cd command is used to change the directories options: cd .Current directory cd .. back to one directory cd ../../ go back two directories.

  8. Pathnames Use the pwd command to print the working directory (the current directory you are in) $ pwd /home $ cd /home/rich/www $ pwd /home/rich/www $

  9. Creating Directories mkdir :command is used to create directories The syntax for the mkdir command is: mkdir directoryname

  10. Copying Files cp:command is used to copy files one one directory to another directory syntax : cp source destination

  11. Moving Files The mv command is used to move a file from one directory to another directory we can also use this command to renaming a file Syntax: mv fromsource todestination mv a.txt b.txt The above command changes file name “a to b”

  12. Removing Files and directories rm : this command is used to remove files and directories syntax: rm [option] file/directory the -rf option can be used to remove the directories and sub directories. rm -rf directoryname

  13. Displaying the contents of a file on the screen In unix we have multiple commands to display the content of a file on the screen some of them are 1.more 2.cat 3.vi editor

  14. more The more command displays the content of a file on the screen syntax: more filename We can't modify the content of a file using more command this is used just for display file content only

  15. cat command Using cat command we can read and modify the content of a file. We can use this command to concatenate files 1.reading a file syntax:cat filename 2.appending text to a file syntax: cat >> filename 3.Over writing file content syntax: cat > filename

  16. Questions???

  17. Thank You

More Related