AMITIAE - Monday 1 October 2012


Command Line Work: New Users and Terminal (8) -- File Commands and More


apple and chopsticks



advertisement


By Graham K. Rogers


Terminal


Ever since the first Macs appeared, they have been known for the graphical user interface (GUI): icons instead of command line work which before the mid-1980s was the norm. Paradoxically, the arrival of OS X brought with it easy access to the command line should users ever want this, although it is possible to use the computer without ever needing to work at the command line at all.


I had a lot of fun last week trying to install some Unix utilities that are not included with OS X: starting with Lynx and wget. The first of these was a text browser I had used in the early days of the world wide web (installed on the server). The other is a utility that allows a user to download all pages from a site for later reading. I am afraid that with both, time has taken its toll.

With the installation of wget I had to resort to some utilities that most Mac users will be unaware of: sudo, mkdir, mv; and I also reminded myself of cp (superuser, make directory, move and copy).

The installation of wget from files that were last updated a few years ago, needed me to create directories inside directories that already existed and then move the files to those locations.

Some locations can only be used by the Root user. By default OS X has no password for this. While some may argue that giving Root a password is not a problem, I would advise against this. In several years of OS X use, the only time I have needed to execute Root commands, sudo allowed sufficient acccess for the task.

This command allows a permitted user to execute a command as the superuser (or execution of a command as another user). The sudo command can only be used in an Admin account, so for this (and a couple of other similar installations), I had drag the files into the Dropbox in the user's Public folder and switch accounts.

Working in Terminal in that Admin account, I had to create three directories. One was a directory called etc in the /usr/local folder. As I prefer working in the specific directory for this type of job rather than entering a path, I typed in the command to switch to the specific directory I needed,

cd /usr/local


I then needed to create a directory named etc with the mkdir command,

mkdir etc

As the permissions here (the /usr/local folder) are limited, I also needed the sudo command, so the full entry was

sudo mkdir etc


After entering the Admin password when I was prompted for it, the directory was created. I was then able to move the specific file into the new folder.

That file was in the Downloads folder. After typing in the command,

sudo mv

I clicked on that file in the Finder and dragged it to the command line: this creates the correct path to the file. I added the new location to the end of the text line (note the 3 spaces here -- between each component of the command):

sudo mv /Users/graham/Downloads/wget/wgetrc /usr/local/etc



With a utility I downloaded last week there was a need to give the file another name, but I also wanted to keep the original. Instead of mv I used the cp (copy) command.

cp filename1 filename2

The duplicate was alongside the original in the folder.



Misuse of any of these commands might cause problems, so users are advised, If in doubt, don't.

The commands outlined here all have manual entries which may be examined using the man command followed by a space, then the command name (man sudo, man mkdir, man mv and man cp).


To be continued. . . .



See Also -

  • New Users and Terminal (1) -- A Quick Look Round
  • New Users and Terminal (2) -- Basic Navigation
  • New Users and Terminal (3) -- Shell Basics
  • New Users and Terminal (4) -- Lists and Manuals
  • New Users and Terminal (5) -- Internet Use
  • New Users and Terminal (6) -- Questions of Identity
  • New Users and Terminal (7) -- A Little More Discovery
  • New Users and Terminal (9) -- Process Identification and Termination
  • New Users and Terminal (10) -- Browsing the Web using Unix
  • New Users and Terminal (11) -- Unix Tricks from OS X Daily
  • New Users and Terminal (12) -- Installed Text Editors - emacs, nano, pico, vi and vim
  • New Users and Terminal (13) -- Installing and Using the Utility, WGET
  • New Users and Terminal (14) -- Passwords, Purging and Closing Notes
  • New Users and Terminal (15) -- Permissions and chmod


    Graham K. Rogers teaches at the Faculty of Engineering, Mahidol University in Thailand. He wrote in the Bangkok Post, Database supplement on IT subjects. For the last seven years of Database he wrote a column on Apple and Macs.


  • advertisement



    Google


    Made on Mac

    For further information, e-mail to

    information Tag information Tag

    Back to eXtensions
    Back to Home Page