Managing Files Commands

Posted by admin | Linux Commands | Saturday 5 July 2008 8:30 pm

PAGE TAGS: linux move command, linux copy command, linux remove command, linux delete command, linux cp command, linux mv command, linux commands delete, linux delete directory command, linux move, linux copy, linux remove, cp, rm, mv

LINUX MANAGING FILES

cp source destination = Copy a file to a new location. When you copy a file, you create a new file. File ownership and permission comes from the user who ran the cp command. Example: cp proj /ongoing/projects

mkdir directory name = Create a directory. Example: mkdir projects creates a projects directory in the current working directory.

mkdir -p path = Create a directory tree structure. Example: mkdir -p completed/projects creates the completed/projects subdirectory in the current working directory.

mv source destination = Move a file to a new location. This is also the command used to rename an existing file using a new name. When you move a file, permissions stay the same (although you need the permissions to move the file).

rm filename = Delete a file.

rm -f filename = Delete a file without a warning prompt.

rmdir directory = Delete a directory (the directory must be empty).

rm -r directory = Delete a directory and its contents (use the -rf switches together to delete without prompting). Take care with this command because rm -rf* deletes all files in the system.