How to Copy, move, rename, and remove files in Linux
->
< Copying >
To copy files, you use the cp
command. The following will copy file
to file2
. Note that if file2
doesn't exist, it'll be created, but if it exists, it'll be overwritten:
$ cp file file2
There aren't any undo commands in the Linux CLI, so accidentally overwriting an important file would probably make you pull your head off. The risk of doing so is smaller if you use the -i
option ("interactive") with cp
. The following does the same as the above, but if file2
exists, you'll be prompted before overwriting:
$ cp -i file file2
cp: overwrite `file2'? n
$
So it's a good idea to use the -i
option whenever you're dealing with important files you don't want to lose!
If you want to copy file
into directory dir1
:
$ cp file dir1
The following would do the same as the above, copy file
into dir1
, but under a different name:
$ cp file dir1/file2
You can also copy multiple files into one directory with a single command:
$ cp file1 file2 file3 dir1
Note that if the last argument isn't a directory name, you'll get an error message complaining about it.
< Moving and renaming >
The mv
command can be used for moving or renaming files. To rename a file, you can use it like this:
$ mv file file2
If file2
doesn't exist, it'll be created, but if it exists, it'll be overwritten. If you want to be prompted before overwriting files, you can use the -i
option the same way as with cp
:
$ mv -i file file2
mv: overwrite `file2'? y
$
To move the file into another directory:
$ mv file dir1
If you want to rename the file to file2
and move it into another directory, you probably already figured out the command:
$ mv file dir1/file2
< Removing files >
The rm
command is used for removing files and directories. To remove a file:
$ rm file
If you use the -i
option, you'll be prompted before removing the file:
$ rm -i file
You can also delete more files at once:
rm file1 file2
Be careful with the rm
command! As I already told you, Linux doesn't have any undo commands, and it doesn't put files into Trash where you can save them later. Once you've deleted a file.
Ubuntu, fedora, centos, linux
How to allow your visitor to bookmark your website
->
Here is how you can allow your visitor to bookmark your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <!-- START OF Add Bookmark in IE DHTML --> <!-- SUMMARY BRIEF This code will allow you to put a link on your page that, when clicked, will add a URL to the user's Favorites. NOTE: This will only work for IE users. It will NOT work for users using Netscape. You can change the bookmark link and text in the var bookmarkurl and var bookmarktitle attributes below. You can change the text of the actual link in the <A HREF> code that you will place for your link to appear in your page. It is located at the bottom of this page. --> <!-- Put this code inside of your <HEAD> tag. --> <script language="JavaScript1.2"> <!-- var bookmarkurl="http://www.javaScriptfreecode.com/" var bookmarktitle="-=[ Java Web Site ]=-" function ccaddbookmark() { if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle) } //--> </script> <!-- Put this code into your page wherever you want the link to be. --> <a href="javascript:ccaddbookmark()" target="_self"> <font size="1" face="Arial">[ Add Webloger to your Favorites ]</font> </a> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"> <span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
Have firelights after the mouse on your website
Here is how you can have firelights after the mouse on your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <STYLE TYPE="text/css"> <!-- BODY{ overflow:scroll; overflow-x:hidden; } .s1 { position : absolute; font-size : 10pt; color : blue; visibility: hidden; } .s2 { position : absolute; font-size : 18pt; color : red; visibility : hidden; } .s3 { position : absolute; font-size : 14pt; color : gold; visibility : hidden; } .s4 { position : absolute; font-size : 12pt; color : lime; visibility : hidden; } //--> </STYLE> <DIV ID="div1">*</DIV> <DIV ID="div2">*</DIV> <DIV ID="div3">*</DIV> <DIV ID="div4">*</DIV> <p align="center"> <font face="arial, helvetica" size="-2"><a Kit</a></font></p> <SCRIPT LANGUAGE="javascript" TYPE="text/javascript"> var nav = (document.layers); var tmr = null; var spd = 50; var x = 0; var x_offset = 5; var y = 0; var y_offset = 15; if(nav) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = get_mouse; function get_mouse(e) { x = (nav) ? e.pageX : event.clientX+document.body.scrollLeft; y = (nav) ? e.pageY : event.clientY+document.body.scrollTop; x += x_offset; y += y_offset; beam(1); } function beam(n) { if(n<5) { if(nav) { eval("document.div"+n+".top="+y); eval("document.div"+n+".left="+x); eval("document.div"+n+".visibility='visible'"); } else { eval("div"+n+".style.top="+y); eval("div"+n+".style.left="+x); eval("div"+n+".style.visibility='visible'"); } n++; tmr=setTimeout("beam("+n+")",spd); } else { clearTimeout(tmr); fade(4); } } function fade(n) { if(n>0) { if(nav)eval("document.div"+n+".visibility='hidden'"); else eval("div"+n+".style.visibility='hidden'"); n--; tmr=setTimeout("fade("+n+")",spd); } else clearTimeout(tmr); } // --> </SCRIPT><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
Have fancy exploding stars on your website
Here is how you can have fancy exploding stars on your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script LANGUAGE="JavaScript1.2"> <!-- //set Interval between each firework display, var intervals=2000 var sparksOn = true; var speed = 25; var power = 1; //Dont change these values------- var documentWidth=documentHeight=randomx=randomy=leftcorner=topcorner=0 var ns=(document.layers); var ie=(document.all); var sparksAflyin = false; var allDivs = new Array(10); var totalSparks = 0; //------------------------------- function initAll(){ if(!ns && !ie){ sparksOn = false; return; } setInterval("firework()",intervals) if (ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE); for(dNum=0; dNum<7; ++dNum){ if(ie) allDivs[dNum]=eval('document.all.sDiv'+dNum+'.style'); else allDivs[dNum]=eval('document.layers["sDiv'+dNum+'"]'); } } function firework(){ //below code detects the browser dimenions if (ie){ documentWidth=document.body.clientWidth documentHeight=document.body.clientHeight leftcorner=document.body.scrollLeft topcorner=document.body.scrollTop } else if (ns){ documentWidth=window.innerWidth documentHeight=window.innerHeight leftcorner=pageXOffset topcorner=pageYOffset } //below code randomly generates a set of coordinates that fall within the dimension randomx=leftcorner+Math.floor(Math.random()*documentWidth) randomy=topcorner+Math.floor(Math.random()*documentHeight) if(sparksOn){ if(!sparksAflyin){ sparksAflyin=true; totalSparks=0; for(var spark=0;spark<=6;spark++){ dx=Math.round(Math.random()*50); dy=Math.round(Math.random()*50); moveTo(spark,randomx,randomy,dx,dy); } } } } function moveTo(i,tempx,tempy,dx,dy){ if(ie){ if(tempy+80>(document.body.offsetHeight+document.body.scrollTop)) tempy=document.body.offsetHeight+document.body.scrollTop-80; if(tempx+80>(document.body.offsetWidth+document.body.scrollLeft)) tempx=document.body.offsetWidth+document.body.scrollLeft-80; } if(tempx>-50&&tempy>-50){ tempx+=dx;tempy+=dy; allDivs[i].left=tempx; allDivs[i].top=tempy; dx-=power;dy-=power; setTimeout("moveTo("+i+","+tempx+","+tempy+","+dx+","+dy+")",speed) } else ++totalSparks if(totalSparks==7){ sparksAflyin=false; totalSparks=0; } } window.onload=initAll //End--> </script> <style> #sDiv0 {position:absolute; height:1; width:1; font-family:arial black; font-size:25px; color:Aqua;} #sDiv1 {position:absolute; height:1; width:1; font-family:arial black; font-size:22px; color:red;} #sDiv2 {position:absolute; height:1; width:1; font-family:arial black; font-size:20px; color:blue;} #sDiv3 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:orange;} #sDiv4 {position:absolute; height:1; width:1; font-family:arial black; font-size:25px; color:yellow;} #sDiv5 {position:absolute; height:1; width:1; font-family:arial black; font-size:25px; color:lightgreen;} #sDiv6 {position:absolute; height:1; width:1; font-family:arial black; font-size:20px; color:silver;} </style> <p></p> <div id="sDiv0"> *</div> <div id="sDiv1"> *</div> <div id="sDiv2"> *</div> <div id="sDiv3"> *</div> <div id="sDiv4"> *</div> <div id="sDiv5"> *</div> <div id="sDiv6"> *</div><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
Have a romantic butterfully appear on your website
Here is how you can have a romantic butterful appear on your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script language="JavaScript1.2"> //specify path to cursor image var cursorpath="http://www.javascriptfreecode.com/fly2.gif" if (document.layers) {document.write("<LAYER NAME='PoInTeRs' LEFT=800 TOP=10><img src='"+cursorpath+"' width=17 height=22></LAYER>")} else if (document.all){document.write("<div id='pOiNtErS' style='position:absolute;top:10px;left:10px;width:17px;height:22px;z-index:50'><img src='"+cursorpath+"' width=40 height=40></div>")} count=-1; move=1; function Curve(){ abc=new Array(0,1,1,1,2,3,4,0,6,-1,-1,-1,-2,-3,-4,0,-6) for (i=0; i < abc.length; i++) {var C=Math.round(Math.random()*[i])} howbend=abc[C]; setTimeout('Curve()',1900); return howbend; } ypos=100; xpos=100; degree = 600; function MoveRandom(){ PathBend=degree+=howbend;//ok! y = 4*Math.sin(PathBend*Math.PI/180); x = 6*Math.cos(PathBend*Math.PI/180); if (document.layers){ ypos+=y; xpos+=x; document.PoInTeRs.top=ypos+window.pageYOffset; document.PoInTeRs.left=xpos+window.pageXOffset; } else if (document.all){ ypos+=y; xpos+=x; document.all.pOiNtErS.style.top=ypos+document.body.scrollTop; document.all.pOiNtErS.style.left=xpos+document.body.scrollLeft; } T=setTimeout('MoveRandom()',50); } function edges(){ if (document.layers){ if (document.PoInTeRs.left >= window.innerWidth-40+window.pageXOffset)degree=Math.round(Math.random()*45+157.5); if (document.PoInTeRs.top >= window.innerHeight-30+window.pageYOffset)degree=Math.round(Math.random()*45-112.5); if (document.PoInTeRs.top <= 2+window.pageYOffset) degree = Math.round(Math.random()*45+67.5);//OK! if (document.PoInTeRs.left <= 2+window.pageXOffset) degree = Math.round(Math.random()*45-22.5);//OK! } else if (document.all) { if (document.all.pOiNtErS.style.pixelLeft >= document.body.offsetWidth-45+document.body.scrollLeft)degree=Math.round(Math.random()*45+157.5); if (document.all.pOiNtErS.style.pixelTop >= document.body.offsetHeight-35+document.body.scrollTop)degree=Math.round(Math.random()*45-112.5); if (document.all.pOiNtErS.style.pixelTop <= 2+document.body.scrollTop) degree = Math.round(Math.random()*45+67.5);//OK! if (document.all.pOiNtErS.style.pixelLeft <= 2+document.body.scrollLeft) degree = Math.round(Math.random()*45-22.5);//OK! } setTimeout('edges()',100); } function starteffect(){ Curve(); MoveRandom();// onUnload="opener.gO()" edges(); } if (document.all||document.layers) window.onload=starteffect </script><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to show the number of visitors online on your website
Here is how you can show the number of visitors online on your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <!-- Start FastOnlineUsers.com --> Oneline users : <script src=http://fastonlineusers.com/online.php?d=www.YOUR WEB NAME.com> </script> <!-- End FastOnlineUsers.com --> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to prevent or stop right click on your website
Here is how you can prevent right click on your website. This will stop people from looking at the source code of your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <SCRIPT language=JavaScript> document.onmousedown=click var times=0 var times2=10 function click() { if ((event.button==2) || (event.button==3)) { if (times>=1) { bye() } alert("No right clicking!!!!!! don't do it again.."); times++ } } function bye() { alert("I said NO right clicking! click ok to exit LMAO!"); bye() } </SCRIPT><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to add a calendar to your website
Here is how you can add a calendar to your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <pre><center> <script LANGUAGE="JavaScript"> <!-- Begin monthnames = new Array( "January", "Februrary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Decemeber"); var linkcount=0; function addlink(month, day, href) { var entry = new Array(3); entry[0] = month; entry[1] = day; entry[2] = href; this[linkcount++] = entry; } Array.prototype.addlink = addlink; linkdays = new Array(); monthdays = new Array(12); monthdays[0]=31; monthdays[1]=28; monthdays[2]=31; monthdays[3]=30; monthdays[4]=31; monthdays[5]=30; monthdays[6]=31; monthdays[7]=31; monthdays[8]=30; monthdays[9]=31; monthdays[10]=30; monthdays[11]=31; todayDate=new Date(); thisday=todayDate.getDay(); thismonth=todayDate.getMonth(); thisdate=todayDate.getDate(); thisyear=todayDate.getYear(); thisyear = thisyear % 100; thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear)); if (((thisyear % 4 == 0) && !(thisyear % 100 == 0)) ||(thisyear % 400 == 0)) monthdays[1]++; startspaces=thisdate; while (startspaces > 7) startspaces-=7; startspaces = thisday - startspaces + 1; if (startspaces < 0) startspaces+=7; document.write("<table border=2 bgcolor=white "); document.write("bordercolor=black><font color=black>"); document.write("<tr><td colspan=7><center><strong>" + monthnames[thismonth] + " " + thisyear + "</strong></center></font></td></tr>"); document.write("<tr>"); document.write("<td align=center>Su</td>"); document.write("<td align=center>M</td>"); document.write("<td align=center>Tu</td>"); document.write("<td align=center>W</td>"); document.write("<td align=center>Th</td>"); document.write("<td align=center>F</td>"); document.write("<td align=center>Sa</td>"); document.write("</tr>"); document.write("<tr>"); for (s=0;s<startspaces;s++) { document.write("<td> </td>"); } count=1; while (count <= monthdays[thismonth]) { for (b = startspaces;b<7;b++) { linktrue=false; document.write("<td>"); for (c=0;c<linkdays.length;c++) { if (linkdays != null) { if ((linkdays[0]==thismonth + 1) && (linkdays[1]==count)) { document.write("<a href=\"" + linkdays[2] + "\">"); linktrue=true; } } } if (count==thisdate) { document.write("<font color='FF0000'><strong>"); } if (count <= monthdays[thismonth]) { document.write(count); } else { document.write(" "); } if (count==thisdate) { document.write("</strong></font>"); } if (linktrue) document.write("</a>"); document.write("</td>"); count++; } document.write("</tr>"); document.write("<tr>"); startspaces=0; } document.write("</table></p>"); // End --> </script> </center></pre> <!-- END CODE - Powered javascript code by WWW.webloger.5u.COM طراحی وبلاگ--> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>