For copying file contents;
cp [options] <file path1><file path2>
cp [options] <file path><directory path>
-u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing.
Remove any file2 and turn file1 into file2;
mv [options] <file path1><file path2>
If no directory exists rename directory1 as directory2, else move directory1 as sub-directory of directory2;
mv [options] <directory path1><directory path2>
Move files into directory;
mv [options] <file path><directory path>
mkdir <directory name>
mkdir -p -m 444 <directory path>
the -p causes the entire directory path to be created.
the -m allows the access mode to be entered.
Remove a directory and sub-tree
rm -rf <directory path>
Files and directories are actually represented in the filing system by a number called an inode and when we see a named file in a directory it is actually just a hard link to the inode and thus the file. Another hardlink can be created effectively giving the same file an additional name and place in the file system tree;
ln <old file path> [<new file name>]
The link will be created in the current directory. Leave out <new file name> if you want the link to be given the same name as the original.
Now there are apparently two possibly differently named files that actually refer to the same file on the storage medium. The actual data will only be deleted when both these references have been deleted.
Linux does not allow users to create hard links to directories, only to files, only the root account can create hard links to directories if it adds the -d flag. The reason for this is that it is quite easy to mess up the file system creating directories that contain themselves! this causes problems for programs that recurs the file system tree.
One can create hard links on mass with;
cp -l <usual parameters>
Which copies a file structure but instead of copying the files it just puts hard links!
A softlink, is a reference to the original file name not the inode;
ln -s <path> [<reference name>]
The link will be created in the current directory. Leave out <reference name> if you want the link to be given the same name as the original.
You could give an abolute <path> like;
will only be broken if the destination file or directory is moved but can be copied anywhere.
Or a relative file path from the directory that the soft link will be in, like;
A relative path like Desktop/foo will be broken if the destination file or directory is moved with respect to the directory that contains the link, and so this means you can copy or move the whole structure in any way that keeps their relative positions in tact. This link must be contained in the same directory that contains "Desktop" for it to work.
Copying can a problem. When we copy an absolute soft link it points to the same file as the soft link it is a copy of. So if we want a copy of a soft link to to point to the copy of the file then it has to be a relative softlink i.e. the softlink path has to be relative to the location where the soft link is intended to operate.