This article contains a list of commands that are commonly used when manipulating files on a Unix/Linux operating system.
Why A List?
Like most of you, I am most familiar with the Windows operating system over Unix/Linux. However, also like the majority, I use a Unix/Linux operating system as a basis for my webhosting. Because I do not work with a Unix/Linux system often enough, it usually means that I have to search on the web for a refresher on the various commands available to me. This is the reason behind this list: a list of commands that are commonly used on Unix/Linux webservers.
This list was partially compiled by a friend and colleague of mine named Brent Baker. You can visit his website here.
Without further ado, here is the list of common commands, their meanings, and samples:
Moves a file from one location (SRC) to another (DEST). “-i” will prompt the user if the DEST file already exists and will ask the user if the file should be overwritten.
Similar to “mv”. Copies a file from one location (SRC) to another (DEST). “-i” will prompt the user if the DEST file already exists and will ask the user if the file should be overwritten.
> mv SRC DEST > mv -i SRC DEST > cp SRC DEST > cp -i SRC DEST
Lists files in the current directory. Similar to “dir” in DOS. There are several command line options available; some of which are:
- a: includes hidden files
- l: long file format – includes date, time, permissions, etc
- R: recursively lists all files in subdirectories
Just like in DOS and Windows, wildcards are able to be used. The sample uses the asterisk to replace one or more characters. You may also use the question mark to replace one and only one character.
Preceding any command with “man” displays help (or the main page) on the command in question. The sample shall display help on the “ls” command.
> man ls > ls -al > ls foo*
Changes the current directory to DIR. “-” undoes the last directory change. “~” makes the home directory current.
> cd DIR > cd - > cd ~
Deletes FILE. “-i” shall prompt the user to confirm each file deletion. Notice that this is just used for files, not directories.
> rm FILE > rm -i FILE
Coupled with a pipe sign (|), this command pauses text that would normally scroll over a screen length vertically.
> ls | more
Creates a directory (DIR) that resides in the current directory.
Deletes a directory (DIR).
> mkdir DIR > rmdir DIR
Clears the current screen of all text.