The Most Important and Common things which you must know, -> How to Copy files, How to move files, and How to rename files in Command Line.
a). cp -> "cp" is the command for copying the file, and how to use it.
cp [your source directory here] [directory where to put copied files] Example cp /usr/local/woh /var/www/
Above Command will copy woh file/folder to www folder of /var/ directory.
If you use "-r" after cp, it will copy all files as "-r" means recursive, For Example.
cp -r ~ /backup/username/
This will copy all files from current directory to your user folder in backup directory.
b). mv -> "mv" command is for move and it is done in same way as copy command, try this yourself as i have already taught you above how to copy.
c). ln -> This command is not much used but can be sometime very handy too, What this does is this creates link and link can be of two types, [One] Hard Link which means after making link if you do change in 1 directory the other will remain as it is, so not always recommendable and the [Second]-> [ln -s] is soft links which means when you make link and so some changes in 1 directory the other directory will get updated too.
d). rm -> This command is used to delete the files, but remember to delete the files you need to have rights to delete the file, most of the time linux will ask for authentication but using "-f" command will force delete the file without asking you. w3clan will continue with some more handy command below.
Deleting large number of files :- Use this command
// Use delete command with caution, it's damage are hardly recoverable. rm -f *
to delete all the files from the directory.
Removing Directories :- Use
to delete the directory.
Removing Directories and Files :- Use [-rf] to remove all folders, subfolders and directories all at once.
rm -rf /usr/local/apache
all files and folder in apache directory will get out from your linux distro, w3clan likes this lol.
d). mkdir -> "mkdir" command will make directory.
A new directory of w3box will get created in current directory the one you are using.
e). Viewing and Editing Files:-
cat filename | more :- "cat your_filename" will display all the content of your filename, If you dont use more than all the page will be scrolled to last, it doesnt matter if you have 1 page but if you have more than one page than its recommended to use "|more" or "|less" command. To terminate, press <q> withour brackets vi filename :- This command will provide you simple and standard text editor. There are other text editor to choose too like :- emacs your_filename -> This will open your file with emacs text editor. kwrite your_filename -> This will open your file with kwrite text editor. nedit your_filename -> This will open your file with nedit text editor. vim your_filename -> This will open your file with vim text editor.
Finding files If you are thinking how to find files than w3clan will teach you here how to find files what you need to do is just follow below commands:-
1). find / -name "filename" -> This command wil find your file of "filename" from root directory. "-name" is command type and "find /" means find from root directory, as we know whole linux is setup in 1 directory thus it will search from "/" root.
Now, we have command
2). locate "filename" -> This command will find the file of name "filename", it is quick.
4). Shutting Down
exit -> If there is one shell running than system will be shutdown, if there is more than 1 shell than it will just logout current user shutdown -h now -> This command when used by root user will shutdown the system to a halt. halt-> This command will halt the machine. reboot-> w3clan think he dont need to explain what this will do. reset-> This command will reset the machine if it gets frozen, in linux few times when you type something than its not visible but machine will do its work whatever valid command you have type. poweroff-> Similar to shutdown.
Related Results :
- Related Posts are generally User Blog posts.
- or Other tutorials from other networks of w3clan.com.
- Any registered user can create related posts based on search term tags.