Q. How do I view the contents of a file?
A. cat filename
The cat command will display the contents of a file.
Q. How do I view the contents of a file when it is too long to view on the screen?
A. more filename
The more command will allow you to view the contents of a file screen by screen. Pressing the space bar will advance the file one more screen. Pressing the return key will advance the file one more line.
Q. How do I create a directory?
A. mkdir directoryname
The directory will be created at the user’s current working directory, unless a specific location is specified along with the directory name.
Q. How do I determine my current working directory?
The pwd command will display where you are currently working in the file system.
Q. How do I create a file?
A. touch filename
The touch command will create an empty file with the filename you choose. You can also use a text editor such as vi or emacs to create or edit a file.
Q. How do I create or open a file in vi?
A. vi filename
If the file already exists, it will open for editing. Otherwise, a blank document will open for editing.
Q. How do I delete a file?
A. rm filename
The rm command deletes a file. Some users prefer to use rm -i filename because it will issue a prompt to verify the delete command before executing it.
Q. How do I see who is logged in to a unix machine?
The who command will list the users currently connected to the computer.
Q. How do I know what user I’m currently logged in as?
The whoami command will display the user name that is currently logged in to the unix machine.
Q. How do I see a list of files?
The ls command will display a list of filenames in the current working directory. The ls -l command will display other information along with the filename, such as last modified date and file permission information.
Q. How do I copy a file?
A. cp oldfilename newfilename
One file can be copied to another using the cp command. Directories can be added to copy files from one location to another, as in cp olddirectory/oldfilename newdirectory/newfilename.