I’ve been learning Shell programming in class, and thought it would be useful to put up some of the more important commands for myself, and others to refer to if necessary.
Help with any Unix command
-manual page for the command, how to use it, dependencies, etc.
-works similarly as the man command, beneficial
Listing directories
-lists the directories, and files in the current folder
-lists the directories, and files in the path location
-lists the date, size, and permissions of the directories and files in the current location
-lists all files, including .dot files (which remain hidden otherwise)
Changing to a directory
-changes to given directory if it is a child of current directory
-goes up one level, to the parent directory
-works in the same way as “cd ..” (goes up one level to the parent directory)
-goes to home directory
Making a new directory
-creates a new director with
Removing a directory
-removes directory iff is empty
-removes directory and all subdirectories and files
Making a new file
-write whatever you like, and you can save it. VIM is the provided text editor.
-write whatever you like and press Ctrl+d to save (can enter multiple lines)
Remove a file
-removes a file
Renaming a file
-renames file <oldfile> to <newfile>
Copying a directory
- cp -r dir1> <destinationPath>
-recursively copy directory <dir1> and all subdirectories to <destination>
- cp <file> <destinationPath>
-copies file <file> to destination <destinationPath>
Viewing text files
-view file, one screen at a time
-view file, allows scrolling
-vi is the VIM text editor, allows you to view the file
Editing text files
-comes with the Bourne shell. Emacs and others are also available.
- cat <newfile> >> <otherfile>
-appends file <newfile> to <otherFile>
Other text commands
-find the <pattern> in <file>
-count words in file <file>
Pipes and redirection
-redirect output to a file
-append output to existing file
-get input from a file
-pipe one command to another
Permissions
The properties of a file or directory are as follows:
uuugggooo (meaning, the first three permissions are for the user, the next three for the group, and the last three are for the world, or others).
The user, group, and world all have rwx (read, write, execute) permissions, in that order. To view permissions,
ls -l
The first character in the properties line will be either a “-“ or a “d”. A “-“ means it is of type file, and “d” means it is a directory. So the entire formation would look something like:
-rwxr-xr-x or
dr——-x
The first is a file, the second is a directory. To change permissions do:
-gives the user read and write permissions for the file <filename>
-gives everyone read, write, and execute permissions for file <filename>
-removes execute permission from the user for file <filename>
I found myself using these the most frequently, but if you need more help or direction check out the following:
Linux Journal
Linux Help
Linux Questions
Excellent list of all UNIX commands