Tag: cp

By Rand Whitehall

To copy a file in the Linux command line interface (cli) then use the cp command. If you are familiar with DOS, cp is like the COPY command. To copy a file you need to write the name of the file you want to copy and the name of the newly copied file.

So, to make a copy of my file called joe and name the new file joe2, I type:

cp joe joe2

I then issue the ls command to show a list of the current files in the directory and I should see my old file joe and a new file called joe2 which is an exact copy of tom.

Now what if I wanted to copy the file joe, but put the copy in another directory? Well, then I simply specify which directory I want the copy to go into.

cp joe Documents/joe2

This will copy the file joe, name the new copy joe2, and place joe2 in the Documents directory. So with one simple command I copied, renamed, and moved a file. It took under a second. If I had done that in the GUI (graphical user interface) it would have taken at least a minute and a bunch of clicks.

What if I type this?: (hint: Documents is a directory.)

cp joe Documents/

Well, if you said a new copy of joe (named joe) would be created in the Documents directory, then you’d be right.

Since we did not specify a name for our copy, but did specify a directory, cp simply used the original name.

What if we do this?:

cp bashcp joe

The output is this an error:

cp: missing destination file operand after `joe’

Try `cp –help’ for more information.

Oops. cp needs a destination, which is either a new name for the copied file, or another directory to place the copy into.

I hope this helps you understand the basics of the GNU Linux command cp. The more you learn about the different cli commands, the more you can do. Soon you’ll be saving tons of time using the cli to perform tasks that would have taken the GUI hundreds of clicks.

Please be careful, though, when starting out with the cli. The command line tools can perform just about any task quickly and efficiently. But it’s easy to damage your system if you accidentally delete something or move a file that shouldn’t have been moved. The cli is like a very sharp katana that can slice through just any problem you may have, but it can also do unintended harm if you aren’t careful.

So when starting out, it’s best to work in safe, “sandbox” directories, on files you have created specifically to learn cli commands. I usually make a new directory, then copy a few files in to play with, so if I screw up, it’s no problem.

Rand writes about web design, men’s health and nitrile gloves. Please check out his new website all about allergy free Nitrile Gloves for info and nitrile glove know how! Check out the Nitrile Gloves vs. Latex Gloves page to find out how nitrile stacks up against latex.

Tags: , , ,

Important Unix Commands That You Should Know

By Bernard Peh

Unix is one of the most important operating system today. Its powerful features, scalability, strong security, and support for multiple users have made it the top choice operating systems for server, workstations and mainframes.

It is good to have some knowledge of Unix commands especially if your web host is Unix/Linux based. You could do alot of things by yourself by logging into the server via Secure Shell(SSH). This article will describe some of the important “need to know” Unix commands.

1. ls

This command will show you what files are in your current directory. If you add in a -F option, ie “ls -F xxx”, there will be a “/” appended to the end of directory names, * to executables and @ to links. “ls -a xxx” will display all hidden files as well. This is also the most used command.

2. cd

Change directory. If you type “cd xx”, it means to change to the specified directory “xx”. “cd ~” means to change to your default home directory.

3. cp “a b”

Copy file a to b. If b is a directory, the new file will be named b/a.

4. mv “a b”

Move files from a to b. For example, if I type “mv songs.txt /tmp”, the file songs.txt will be moved to /tmp/songs.txt. Moving a file is the same as renaming a file.

5. echo “text”

Print “text” to the terminal. If “text” is surrounded by double quotes, the text will be printed with any environment variables such as $HOME. If “text” is surrounded by single quotes, the “text” is printed without any special processing.

6. pwd

Print the current working directory. Useful command when you are lost in the directories.

7. cat “file”

Print the contents of the specified file(s) to the terminal.

8. less “file”

Display the specified file one screen at a time. Press the spacebar to go to the next screen. Press Q to quit. You often combine “less” with some other commands such as “cat abc | less”. This command means you print the contents of the file abc and display it one page at a time.

9. ps

Display information about your running programs. This is a good command to use if your server is slow and you suspect that some applications are taking too much memory. The most famous command using ps is “ps aux”. This will display useful information on the running programs.

10. rm

Remove or delete a file. If you type “rm -r directory”, it will remove a directory and all the files underneath it recursively.

11. man

This is the most important command. man means “manual”. If you are stuck with cat command for example, type “man cat” and you can see the help file.

Bernard Peh is a great passioner of web technologies and one of the co-founders of SiteCritic Website Reviews. He works with experienced web designers and developers for more than 5 years, developing and designing commercial and non-commercial websites. During his free time, he does website reviews,freelance SEO and PHP work.

Tags: , , , , , , , , , , ,

Best Beginners Linux Commands

By Dennis Frank Parker

There are many common Linux commands that will be to your benefit, if you ever even use your command line software in Linux. Many average users just use the graphical user interface instead which usually provides many tools and front-ends to Linux common commands. This Linux system tutorial on control commands will help the average user in the event X server accidents, fails, is not properly designed, etc. So stay with me for some of the more prevalent Linux bash instructions.

Some of the more Best free Linux tutorials. A Linux system Unix shell commands tend to be listed below for more information on each command you can always manage man [command] and this will bring up the manage for that command, you can also click on the requires listed for some frequent examples and format.

First before I list them virtually any syntax in [] will be needing some kind of input of your stuff normally, for example:

guy [command] you will want to actually change [command] with the shell order you want to read the guy page for: gentleman ls will give you the man page for the Linux covering command ls.

    • linux ls command – is used to list files on the filesystem.

 

    • File – command that will check the filetype, this will output to you what the file type is no matter what the extension is.

 

    • Mkdir command – used to make directories on the filesystem.

 

    • cd- is used for changing into a different directory in the Linux shell

 

    • cp – is the Linux copy command, this shell command is used to copy files|directories from one location on the filesystem to another.

 

    • Mv – the Linux terminal command to move files|directories. Like the cp command, but deletes the original source.

 

    • rm- shell command in Linux to remove files|directories.

 

    • Linux cat command- this command is used to print|view the contents of a file to the screen|terminal.

 

    • Grep – command used to search|find contents of a file and print|view on your terminal|screen.

 

    • Linux more and less – commands that will allow you to read output of files, unlike cat that will output the entire file at once, even if it is too large for your terminal more and less will output only as many lines as the shell you are in can output, and allow you to scroll through the file contents.

 

    • Chown – Linux command to change ownership of a file|directory.

 

    • Linux chmod – command that allows you to change mode of user access|permissions, basically set read, write, and execute permissions.

 

    • Linux ps – lists the current running processes on your Linux system

 

  • Linux kill and killall commands – used to kill|terminate running processes

We Provide Best free Linux tutorials and Cbt nuggets training.

Tags: , , , , , , , , , , , , , , ,
Back to top