In our next Terminal tip, we'll show you how to download files from the web. Of course it's probably easier just to use the GUI of Safari, but using Terminal gives you additional stats like file. If you aren’t already familiar with your Mac's command-line interface. First up: How to navigate the file system from the command-line prompt. By default, when you open Terminal, the. I need to download a file from server to my desktop. (UBUNTU 10.04) I don't have a web access to the server, just ssh. If it helps, my OS is Mac OS X and iTerm 2 as a terminal.
Terminal User Guide
In Terminal, you can move and copy files locally or remotely using the mv
, cp
, and scp
command-line tools.
Tip: It’s easier to move and copy files using the Finder. See Organize files in folders.
Move a file or folder locally
In the Terminal app on your Mac, use the
mv
command to move files or folders from one location to another on the same computer. Themv
command moves the file or folder from its old location and puts it in the new location.For example, to move a file from your Downloads folder to a Work folder in your Documents folder:
% mv ~/Downloads/MyFile.txt ~/Documents/Work/MyFile.txt
You can also change the name of the file as it’s moved:
% mv ~/Downloads/MyFile.txt ~/Documents/Work/NewFileName.txt
See the mv command man page.
Copy a file or folder locally
In the Terminal app on your Mac, use the
cp
command to make a copy of a file.For example, to copy a folder named Expenses in your Documents folder to another volume named Data:
% cp -R ~/Documents/Expenses /Volumes/Data/Expenses
The
-R
flag causescp
to copy the folder and its contents. Note that the folder name does not end with a slash, which would change howcp
copies the folder.
See the cp command man page.
Copy a file or folder remotely
In the Terminal app on your Mac, use the
scp
command to copy a file or folder to or from a remote computer.scp
uses the same underlying protocols asssh
.For example, to copy a compressed file from your home folder to another user’s home folder on a remote server:
% scp -E ~/ImportantPapers.tgz username@remoteserver.com:/Users/username/Desktop/ImportantPapers.tgz
You’re prompted for the user’s password.
The
-E
flag preserves extended attributes, resource forks, and ACL information.The
-r
flag, which isn’t used in this example, causesscp
to copy a folder and its contents.
See the scp command man page.
As a Linux user, I can't help but spend most of my time on the command line. Not that the GUI is not efficient, but there are things that are simply faster to do with the keyboard.
Think about copy and paste. Select a text you want to copy, go to the edit menu, click, precisely move down to copy, click, then go to the destination, click where you want to paste, go to edit menu, click, move down to the paste option, then paste. Every time I see someone do this, I die a little inside. Sure you can save some time by right-clicking, copy, right-click, paste. But you can save some more time by pressing, ctrl-c then ctrl-v
My hands are already on the keyboard, and I would rather do the mundane things on the keyboard and not think about them.
One thing I do frequently is download files. They can be zip file, tgz, or jpg. On linux, all I have to do is open the command line, run wget with the file I want to download and it is done.
Straight to the point. But how do you do that when you are on a Windows machine? Let me introduce you to cURL, pronounced curl. (i don't know why I wrote it the way I did)
Html Download File From Server
curl is a very powerful tool with too many feature. But I just want to download the file on Windows so let's just learn how to do that.
Open PowerShell. That's Windows Key + R
then type powershell and press enter.
Now run the curl command with the -O
option to specify the file output.
Easy right? Now you can download files right from the command line all by simply using your keyboard.
OK. It is time I confess. This is not the curl tool you are using. It's only an alias. In reality, we are calling the command Invoke-WebRequest
. But hey! It works, so we don't care. You can call it in its native format if you want to.
Either way, now you know how to download a file from the command line.
Did you like this article? You can subscribe to read more awesome ones. Share your insightful comments here.
Sign up for the Newsletter.
Follow me on Twitter,