1 / 13

Linux Basic Commands

Linux Basic Commands. CS 302. Listing files and directories. ls (list) To find out what is in your home directory, type: % Is. Please Note: the default directory is cygwin /home/username where username is your computer username. $ ls –m

kaia
Download Presentation

Linux Basic 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. Linux Basic Commands CS 302

  2. Listing files and directories • ls (list) To find out what is in your home directory, type: % Is Please Note: the default directory is cygwin/home/usernamewhere username is your computer username • $ ls –m • To list files across the page, separated by commas. • $ ls ~ • List the contents of your home directory by adding a tilde after the ls command. • $ ls / • List the contents of your root directory. (Your root directory is Cygwin)

  3. Making Directories • mkdir (make directory) To make a subdirectory in the current directory you are in. Example : to make a subdirectory called newdir in your home directory, type : % mkdir newdir Now you can see the directory you have just created (newdir), by using Is command.

  4. Changing to a different directory • cd (change directory) To change the current working directory to another. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree. To change to the directory you have just made, type % cd newdir Type ls to see the contents (which should be empty)

  5. Changing to a different directory (Cont.) • (..) means the parent of the current directory, so typing % cd .. will take you one directory up the hierarchy (back to your home directory). Try it now. • Note: typing cd with no argument always returns you to your home directory. This is very useful if you are lost in the file system.

  6. Pathnames • pwd (print working directory)  To find out the pathname of your current directory , type : % pwd

  7. Displaying the contents of a file on the screen • cat (concatenate) The command cat can be used to display the contents of a file on the screen. Type: % cat filename.txt • head The head command writes the first ten lines of a file to the screen. Type: % less science.txt • tail The tail command writes the last ten lines of a file to the screen. Type: % tail science.txt

  8. Create empty files • touch Filename When used without any options, touch creates new files for any file names that are provided as arguments. ex.: The following command would create three new, empty files named file1, file2 and file3: touch file1 file2 file3 You can also provide an extension to the file you want to create. Ex: touch file.txt

  9. Movingfiles The command mv moves or renames files. • To rename file: % mv oldfilenamenewfilename % mv abc1 abc2 It will rename the file abc1 to a new name abc2 • To move a file to a directory. use (mv) in the following form: %mv filename directoryname It will move the file into the named directory keeping its old name. %mv abc2 /home/ubuntu/test • Move abc2 file to test directory

  10. Copying files • cp This command makes a copy of file1 in the current workingdirectory and calls it file2. % cp file1 file2

  11. Deleting files • rm filename

  12. Compress files • gzipfilename compresses files, so that they take up much less space. Usually text files compress to about half their original size, but it depends very much on the size of the file and the nature of the contents. There are other tools for this purpose, too (e.g. compress), but gzip usually gives the highest compression rate. Gzip produces files with the ending '.gz' appended to the original filename

  13. Uncompress files • gunzipfilename uncompress files compressed by gzip.

More Related