What command lines do you use, and what are they for?
For those of us Mac users who aren't Unix gurus yet OS X is pretty but we're really only scratching the surface.
I was wondering what commands you old Unix vets know(and new users for that matter)in OSX.
Just a list of what the command is, and what you use it for.
for example, the only one i use with any frequency.
telnet
lets me log into a remote e-mail server. however, sends all my info as plain text and is a huge gaping security problem.
So let's get a thread of useful commands!
-alcimedes
I was wondering what commands you old Unix vets know(and new users for that matter)in OSX.
Just a list of what the command is, and what you use it for.
for example, the only one i use with any frequency.
telnet
lets me log into a remote e-mail server. however, sends all my info as plain text and is a huge gaping security problem.
So let's get a thread of useful commands!
-alcimedes
Comments
...
[ 07-06-2002: Message edited by: Eugene ]</p>
I use a number of commands, but these are some of the more common ones I use:
ls [-la] path: Displays the contents of the foklder passed. If you include the -la part, it will show hidden files too. This is useful if the finder is poky, you are mucking with hidden folders, or if you just performed a command line over or something.
mv oldpath newpath: Moves or renames a file/folder. To rename, just pass the same path with the new filename on the end.
rm [-rf] path: Removes a file, with the -rf part, removes folders as well without confirming anything. WARNING: THIS COMMAND, IF USED IMPROPERLY, CAN WIPE YOUR HARD DISK AND ANY ATTACHED DRIVES WITHOUT BLINKING AN EYE
uptime: Displays how long your computer has been running.
ssh ip address: establishes a secure connection to another computer.
bill gates: you'll have to see for yourself. [be sure to include the space between bill and gates]
bill gates: you'll have to see for yourself. [be sure to include the space between bill and gates] <hr></blockquote>
<img src="graemlins/lol.gif" border="0" alt="[Laughing]" /> <img src="graemlins/lol.gif" border="0" alt="[Laughing]" /> <img src="graemlins/lol.gif" border="0" alt="[Laughing]" />
cp - copy file
cpmac - copy file w/ resource fork
pico - text editor
defaults write com.apple.terminal TerminalOpaqueness '0.50'
It makes the terminal transparent. Change the value between the 'xxx' to set it. Open a new terminal window, change the colors in preferences, and voila you've got a customized terminal window to learn unix in (still learning here).
for those of you with a mile long list, care to break out at least two or three for a real explanation?
-alcimedes
p.s. turns out if you type "bill" then anything else it asks if you want to kill it. wonder if that's just a coincedence.
Just create a new file called 'aliases.mine' in /usr/share/init/tcsh/ and format it like so:
[code]alias p 'pico'
alias sp 'sudo pico' #sudo pico
alias psa 'ps -acex' #list all processes
alias cdl 'cd \\!*; l' #change directory and list
alias b 'cd -' #go to previous directory
alias ... '..;l' #go up one directory and list
alias aliases 'grep "alias" /usr/share/init/tcsh/aliases.mine' #show my aliases</pre><hr></blockquote>
The '#'s are comments. The space after the alias' name is a tab.
I find that 'cdl' is probably my most common alias.
Just type 'cdl nameOfDirectory' and it will change to that directory and list the contents all in one shot. That way you don't have to 'cd' to the directory then 'ls'.
The 'sudo pico' is for when I edit my 'aliases.mine' file.
Aliases are your friend.
And I am a complete Unix n00b! I actually find the command line fun (now that I can type).
<strong>p.s. turns out if you type "bill" then anything else it asks if you want to kill it. wonder if that's just a coincedence.</strong><hr></blockquote>tcsh will search for a similar command if what you entered is not valid. In this case, "bill" is not a command and the closest match is "kill".
e.g. If you type 'cill' it will ask you "OK? kill?" or 'till' or 'gill' etc....
Also, a great terminal feature is tab auto complete.
If you hit the 'tab' key, the terminal will try and guess what you want next.
For example:
Let's say that you are in your "Home" directory. (cd ~) and you want to go to your "Documents" folder. If you type 'cd Do' and press the tab key, it will auto complete the word Documents. If there are more than one directory that start with "Do" then it will give you a list of other possible choices.
This also works with commands. It's a great way to learn what commands exist in the terminal. Just type a letter and hit 'tab'. It will give you a list of all the commands that begin with that letter. Then just do a 'man commandName' to see what that command does.
Ahhh, the Unixy goodness of OSX!
<strong>for those of you with a mile long list, care to break out at least two or three for a real explanation?</strong><hr></blockquote>Well, everything you need to know is in the man pages. Need info on the "grep" command? Simply enter "man grep" to read the grep manual.
Here are a few I use from Eugene's list:
awk - search data for and print pattern
cat - concatenate or print a file
chgrp - change group of a file
chmod - change flags of a file
chown - change owner of a file
crontab - set crontab files
curl - url downloader
cvs - archive downloader, syncs local files with online files
defaults - sets application and system preferences
df - show free disk space
diff - find differences between two files
du - show disk usage
echo - print text
find - find files
grep - search data for and print pattern
gzip - gzip compression tool
head - show first part of a file
kill - quit a process
less - display text
ln - make symbolic link (similar to an alias)
locate - find files using the system's locate database
ls - list files in a directory
make - run makefile for a project
man - display man pages
mkdir - make a new directory
more - similar to less, but less is more
mv - move a file
ncftp - ftp program
niutil - NetInfo configuration tool
open - open a file
passwd - change a password
perl - execute perl commands
ps - show process status, similar to top
pwd - display current directory
renice - change priority of a process
rm - remove file or folder
sh - a simple shell
ssh - secure shell connection
su - become another user
sudo - execute command as another user
sum - checksums a file
tail - show last part of a file
tar - tar archiver
tcsh - the default shell in Mac OS X's terminal
top - display system stats
touch - touch a file
uptime - display computer's uptime
vi - text editor
w - show current users
whoami - show what user you are
whois - use online directory to search names
[ 07-06-2002: Message edited by: starfleetX ]</p>
came back looking for seb's terminal hack, thought some others might like to see it.
mv ./word.doc ./file.doc
will rename word.doc to file.doc
It creates a symbolic link (alias) of a file. I say unfortunately, because if the aliases on OSX worked properly I shouldn't have to break into the command line.
For example, I would like to make an alias of a preference file between two users. This is a requirement for Quicken2002, if you want two users to be able to open/use/save the same quicken file. Well, Quicken can't use the alias pointer requiring a symbolic link instead.
BEFORE everyone jumps on me about how this is Intuit's problem (they have a lot of problems, I agree). I never had this problem in OS9 with any application. THey could use aliases as well as the actual file. So, I'm thinking able should have made the default alias a symbolic link instead of the crappy regular link that it currently uses.
<strong>Unfortunately I have used: ln -s A LOT.
It creates a symbolic link (alias) of a file. I say unfortunately, because if the aliases on OSX worked properly I shouldn't have to break into the command line.
</strong><hr></blockquote>
I know! what the hell is up with that? Is Apple trying to give an aneurysm?
The only thing I figure is that the links are being created to be backwards compatable with OS 9, but I have OS X installed on UFS, so OS 9 wouldn't be able to use that anyway!
Anyway, commands I use a lot:
find - for finding a file, take a lot of options but i like doing this:
find * -name *~ -exec rm {} \\;
which finds all emacs backup files and deletes them.
oh rm - removes a file (permanently), you shouldn't use -f unless it is necessary. Be careful what you do here. -f forces the file to be removed, even if you are not the owner (if you have the privaledge of doing so)
emacs - greatest text editor ever made, vi sucks!
commands you must know to get around:
cd - change directories
cp - copy a file to somewhere else
mv - move a file somwhere
ls - list a directory
ll - shortcut to ls -al
man - tells you everything you need to know about a command, or a C library function.
there are many more...
Why doesn't "apropos" work <img src="confused.gif" border="0">
[ 07-29-2002: Message edited by: MrBillData ]</p>
list the current directory including hidden files in reverse time-order.
grep
It's like what Sherlock may eventually reach as far as finding files/contents is concerned.
netstat
\tinformation about the available network connections. Zillions of options.
ssh
\tYou can think of it as 'just telnet', but it is substantially more secure. ssh is a strict superset of telnet.
top
The textual version of 'process monitor', with a heck of a lot more options.
rm/mv/cp/cd the essentials.
cat filename
Spit the named file to the terminal window.
more filename
Spit the named file to the terminal window one screen at a time (space bar for next page, many, many other options).
man man
Starting place for a ridiculous amount of info.
curl
A better 'ftp' than ftp. Accepts URLs for one thing.
man tcsh
tcsh is the 'shell' that's actually the default running widget when you are typing in the terminal.app. There's a lot of stuff built straight into tcsh, or added to configuration files by Wilfredo Sanchez.
ls
lists the items in the current directory.
top
shows processor and memory usage of running processes. press 'q' to turn it off.
cd [directory name]
change to the named directory. don't actually type the brackets.
kill [process id]
kill or quit a running process. you can run top to find the process id number "pid"
I use many others, but I don't want to tell you anything dangerous and I don't want to list a bunch of commants with no explanations either, but since others did, I'll give you one last command you should like:
man [command]
this will bring up the manual page on how to use a specific command. so, for example, if somebody told you to use chmod for something, you could type "man chmod" and find out what chmod does and how to use it.
"pico" for editing
"ps -ax"for viewing all running processes
"kill XXX" (X's are for what ever # the previous command shows the process ID as.) for killing processes.
ls -al (will do a 'directory listing')
wc (will count things such as lines of text and number of characters)
Now if you add a pipe you can do things like this:
% ls -al | wc
16 137 884
The directory listing that would have been displayed was a total of 16 lines and those lines had total of 137 'words' (anything broken by a tab or a space) and the total number of bytes that made up the listing was 884.
The pipe | can (and is) used ALOT and allows for some really cool things.
Another cool symbol is >
% ls -al > mydirectory
Will take the directory listing that would have normally been output to the screen and instead redirect it to a file called mydirectory.
You can then open that file in any text editor you like.
One more cool symbol is <
%wc < mydirectory
The above command will PUSH the text found in that text file I just created in the last example INTO the unix app called wc (see above). The output from wc was displayed to the screen as usual.
%wc < mydirectory > newfile
In that last example the output from wc was NOT displayed to the screen but instead written to a file called newfile.
While these examples are kinda lame they do show some of the really wild things you can do with unix.
Dave
[ 07-29-2002: Message edited by: DaveGee ]</p>