Create Directory Command:
Don’t forget, UNIX is case sensitive, UPPER CASE directory names are considered to be different from lower case directory names.
mkdir test2 creates a subdirectory called test2 mkdir /tmp/test2 makes a directory called test2 the /tmp directory rmdir test2 removes an empty directory called test2
NOTE : The rmdir command will remove a directory only when empty. To remove a full directory and all it’s contents, use the below command.
rm -r directory_name
The shutdown command can be used to turn off or reboot a computer. Type the command as follows to shutdown server / computer immediately:
Login as root user and type the command in terminal prompt
$ shutdown -h now OR $ shutdown -h 0
Shutdown compute at specific time, To shutdown computer at 6:45pm.
$ shutdown -h 18:45 "Server is going down for maintenance"
At 6:30pm message will go out to all user and 6:45 system will shutdown.
Please note that you can also use halt or poweroff or reboot command for stopping and restarting the system:
$ halt OR $ poweroff
$ reboot OR $ shutdown -r 0
Remove file / directory command:
Remove command deletes files in a directory. Remove command will not produce an output unless you have an error.
NOTE: There is no “undelete” command in UNIX, once you delete a file, it is gone (unless it is on a backup tape). Because of this, the rm command on CMGM and PMGM will ask you if you really want to delete a file before it goes ahead and does it.
Most UNIX commands have a variety of additional command modifiers that can be used to change the output. For example, if you typed
rm -r *
you would delete recursively the contents of a directory. This means the contents of a directory and all directories and files under it.
rm * delete everything in a subdirectory rm *.txt remove only files with a .txt on the end rm data* remove only files that start with the word "data" rm -r dir2 removes everything in the subdirectory "dir2"
Copy file / folder command:
Copy command lets you copy a file from one location to another on a UNIX machine.
cp -r * /tmp copy everything in the directory to the /tmp directory cp file1 file2 copy file1 to a file called file2 cp file1 /tmp copy file1 to the /tmp directory cp file1 ~smith copy file1 to the home directory of "smith"
Move file / folder command:
move command is similar to the copy command, except it copies the file and deletes the original.
mv file1 file2 rename file1 to the name file2. mv file1 /tmp move file1 to the /tmp directory. mv file1 ~sathu move file1 to the home directory of "sathu". mv * /tmp move everything in the directory to the /tmp directory. mv dir2 /tmp move the directory called dir2,and everything in it, to the /tmp directory.