Unix Commands Display File
Posted By admin On 26.10.19Use the following commands to help you manage your UNIX account. IMPORTANT: The UNIX (Ultrix) operating system is case sensitive. All commands must be typed in lower-case letters unless noted otherwise. Displaying a Directory ls- Lists the names of files in a particular UNIX directory. If you type the ls command with no parameters or qualifiers, the command displays the files listed in your current working directory. When you give the ls command, you can add one or more modifiers to get additional information.
Example: ls Result: Lists the names of files in your default directory, in alphabetical order. Example: ls -l Result: Gives a 'long listing' of the files in your directory. In addition to the file name, the long listing shows protection information, file owner, number of characters in file, and the date and time of the last change to the file.
Example: ls -a Result: Causes all your files to be listed, including those files that begin with a period (i.e., hidden files). For more information, type man ls at the UNIX system prompt. Displaying and Concatenating (Combining) Files more- Enables examination of a continuous text one screenful at a time on a terminal. It normally pauses after each screenful, printing - More - at the bottom of the screen. Press RETURN to display one more line.
This is a list of Unix commands as specified by IEEE. Select or reject lines common to two files: Version 4 AT&T UNIX: command: Shell. Display files on a page. Cat command: print all the contents of the file in terminal. If the contents of your file is larger than a page, cat will not stop paging through the program until it hits the end.
Press the SPACE BAR to display another screenful. Press the letter Q to stop displaying the file. Example: more newfile Result: Displays the contents of 'newfile' one screen ('page') at a time. For more information about this command, type man more at the UNIX system prompt. Cat- Displays the contents of a file on your terminal. Nokia 5230 phone software update. Example: cat newfile Result: Displays the contents of the file 'newfile' on your terminal.
Example: cat newfile oldfile Result: Displays the contents of two files - 'newfile' and 'oldfile' - on your terminal as one continuous display. While a file is being displayed, you can interrupt the output by pressing CTRL + C and return to the UNIX system prompt. CTRL + S suspends the terminal display of the file and the processing of the command. To resume display, press CTRL + Q. The interrupted command displays lines beginning at the point at which processing was interrupted.
The cat command is also used to concatenate (combine) files and put them into another file. If you concatenate files to another one that already exists, the existing contents are permanently lost. Example: cat fileone filetwo filethree newfile Result: Links together three files - fileone, filetwo and filethree - into a new file called 'newfile'. The original files remain intact. For more information about the cat command, type man cat at the UNIX system prompt. Copying Files cp- Makes copies of your files. You can use it to make copies of files in your default directory, to copy files from one directory to another directory, or to copy files from other devices.
Example: cp fileone filetwo Result: Copies the contents of fileone to a file named filetwo. Two separate files now exist. Example: cp /usr/neighbor/testfile. Result: Copies the file testfile from the directory /user/neighbor to your UNIX account. ) at the end of the command line indicates that the file is to be copied to your current working directory and the name will remain the same. To copy a file from another user's directory on UNIX, you must know the person's username.
Example: cp username/file1 yourfile Result: Copies the file 'file1' from user to your UNIX account. The name of the file in your directory becomes yourfile. (Protections must be set for file to be readable by you in user abcst's directory in order to be able to copy the file.) For more information, type man cp at the UNIX system prompt. Deleting Files rm- Deletes specific files.
You can enter more than one file specification on a command line by separating the file specifications with spaces. Example: rm newfile Result: Deletes the file named 'newfile'. Example: rm newfile oldfile Result: Deletes two files - 'newfile' and 'oldfile'. Example: rm new. Result: Deletes all files that begin with the prefix new. For more information, type man rm at the UNIX system prompt. Renaming Files mv- This command changes the identification (name) of one or more files.
Example: mv oldfile newfile Result: Changes the name of the file 'oldfile' to 'newfile'. Only one file will exist.
Example: mv oldfile bin/newfile Result: Changes the name of the file 'oldfile' to 'newfile' and places it in the directory /bin. Only one file will exist. For more information, type man mv at the UNIX system prompt. Printing from UNIX The lpr command prints files on UNIX. Use the -Pqueuename option to select a printer.
Example: lpr -Ppittprint sample.file Result: This is the default output. Single-sided output, one page-worth of text per side, portrait format. Output is queued to the Pitt Print Stations. The UNIX operating system is case sensitive; type all commands in lower-case letters unless noted otherwise.
Get Help The Technology Help Desk at 412 62 4-HELP 4357 is available 24 hours a day, seven days a week to answer your technology-related questions. Questions can also be.
Export Display Unix Command
Basic UNIX Commands This document is intended to get you started using the UNIX operating system. It contains basic UNIX commands.
For more advanced information on using UNIX, including creating aliases, setting file protections, and changing your shell script, read our documentation. UNIX commands are case sensitive.
In other words, typing ls is different from typing LS, and it produces different results. In general, it is best to type in lowercase unless uppercase is specifically called for. Many UNIX commands have qualifiers to the commands. The qualifiers are always preceded by a dash ( -). For example, ls -l means list files in the current directory with the long listing.
Qualifier letters do not mean the same things on different commands, but the letter chosen generally makes sense for the particular command. Connecting to a UNIX Machine with a Computer On campus, you may use from a windows machine or from a Mac to log into your UNIX account. When you log into UNIX, you will receive a prompt similar to this: jldoe@maggie-1!
If you entered your user name or password incorrectly, you will be told that your login was incorrect and you will be given the login prompt again. Changing Your Password You may change your password as often as you like. To change your password, type: kpasswd At Old Password: type in the password you used to log in. At New Password: type in a new password. Passwords must be at least eight characters and may contain letters (both small and capitals), numbers, and/or punctuation marks.
At Verify: type in the same new password again. Logging Out To log out of your UNIX account, type logout at the UNIX prompt: jldoe@maggie-1! Logout Creating Files There are several editors available in UNIX to create files: Pico, EMACS, and Vi. The Pico editor is the simplest editor but not as powerful as EMACS or Vi. Vi is the most powerful, but also the hardest to learn. Pico is the same editor that the Pine mail system on UNIX uses. This example shows how to create a sample file with Pico.
Once the file is created, basic commands will be demonstrated using this file. To create a file called sample.txt, at the UNIX prompt type: pico sample.txt You will be given a blank screen. Type in the following text: This is a sample file created with the Pico editor in UNIX. After this file is saved, I will practice using some UNIX commands with this file.
Linux File Commands
Soon, I will be comfortable with the UNIX operating system! Press CTRL+X to save the file. Type Y when asked if you want to save the file under the name sample.txt. Getting a Directory Listing To get a list of the files in your UNIX directory, type: ls You should see the file listed in your directory. To get a listing with more information about the files, type: ls -l Viewing the Contents of a File To see what is in the file, type: more sample.txt The file you just created will be displayed on the screen. If you use the more command with files that are longer than one screen, you will see More at the bottom of the screen. Press the space bar to go to the next screen of information.
Copying a File To make a copy of the file called sample.txt and call it new.txt, type: cp sample.txt new.txt Renaming a File To rename the file new.txt to sample2.txt, type: mv new.txt sample2.txt NOTE: UNIX does not have version numbers on files. Therefore, if you save, copy, or move a file into a file name that already exists, it will OVERWRITE the contents of the existing file. You can avoid this by being very careful about using these commands, OR you can use the -i option on the copy and move commands. The -i option will prompt you if you are about to overwrite an existing file and give you a chance to give the file another name. Cp -i new.txt sample.txt cp: overwrite sample.txt (yes/no)?
Printing a File If you are using a lab at UNCG, then you will probably want to choose a printer in that lab. To do this, type printers at the UNIX prompt. Choose a printer from the list. To print your file type: lp -c filename For example: lp -c sample.txt For more information on printing in UNIX, please read our document.
Creating, Using and Deleting Subdirectories It helps to keep your files organized in subdirectories. To create a subdirectory named learning, type: mkdir learning To get into this directory, type: cd learning To check your location, or path, type: pwd Your path shows you where your current directory is set. Everyone's directory at UNCG starts with /afs/uncg.edu/user/ initial/username. For example, jldoe's path is /afs/uncg.edu/user/j/jldoe. If you change directory to a subdirectory, it becomes part of your path. For example, if jldoe types cd learning then her path would be: /afs/uncg.edu/user/j/jldoe/learning To get back to the home directory type: cd To copy the file named sample.txt into the subdirectory, type: cp sample.txt learning To copy the file called sample.txt into the subdirectory called learning and give it the name sample1.txt, type: cp sample.txt learning/sample1.txt To list the contents of the subdirectory named learning, type: ls learning To delete a subdirectory, first delete all the files from the subdirectory and then use the rmdir command to remove the subdirectory.
For example: To change directory to the subdirectory: cd learning To check the path, to make sure you are in the subdirectory: pwd To list the files in the directory: ls To delete all the files in the subdirectory: rm. To change directory back to the main directory, type: cd To remove the sub-directory, type: rmdir learning Creating a Symbolic Link to a Directory Sometimes users have to work with files in directories other than their own. For example, users who maintain Web pages for departments have to work with files that are in a location other than their own directory.
To get to this directory, users typically have to type in a long command such as the following: cd /afs/uncg.edu/html/eng Creating shortcuts, or symbolic links, makes this command easier to type. To make a shortcut to a directory, type: ln -s dirname linkname For example, if jldoe is in the English department and has access to the English department's HTML directory, she could make the following link: ln -s /afs/uncg.edu/html/eng english From then on, whenever jldoe wants to go to the English department's Web directory, she simply types cd english. UNIX Command Table Command Description cat filename Show me the contents of a file on the screen. Cat file1 file2 Concatenate and display file1 and file2. Cd directory-name Change to the directory named. Change back up one directory level. Cd Change to HOME directory.
Unix File Commands Cheat Sheet
Cp oldfile newfile Copy contents of old file to new file. Ls List files in current directory. Ls -a List all files including hidden files. Ls -al List all files including hidden files, dates and file modes. Man command Obtain a manual page for a command. Man -k string Search all manual pages for a keyword string.
Mkdir dirname Create a directory. Rmdir dirname Remove (delete) a directory. Ln -s target linkname Create a link or association between an existing file or directory (target) and a name that you associate with that file or directory (link name). More filename Display a file on the screen one page at a time. Mv file1 file2 Move file1 to file2. (rename a file) kpasswd Change your password.
Pwd Display your current path. Rm file Remove (delete) a file.
Special Characters in UNIX The following special characters can be used to interrupt or suspend execution of a UNIX command: CTRL+D issues an end of file to the program which will cause some programs to terminate. If you issue a CTRL+D at the UNIX prompt, you will be logged out of UNIX. CTRL+C is the INTERRUPT signal which will terminate a program if it has not been coded to process this signal. CTRL+Z issues a STOP, which suspends the program.
It does not terminate the program. It can be continued later with the fg command or it can be terminated with the kill command.