![]() |
I'm New
i am very new to the whole Unix thing and i would like to know about it because i like to know what my computer can do. i was just wondering if anyone has any nifty neat BASIC things that one can do in the terminal.
thanks |
Type in the "top" command (no quotes) and it displays an updating list of everything running and how much cpu % it's using, etc. I find that very useful...
|
But don't fall in to the habit of leaving 'top' running all the time, it becomes a processor time hog (samples for running processes every second or so).
run "top" then control-c out of it for a "snapshot" of running processes. |
I've found locate to be really helpful. Just type "locate whatever", and it will give you a list of every instance of "whatever"(case-sensitive). Done almost instantly, much, much, much, much, much faster than Sherlock.
|
from the top manual (man top)
top -u -s5 20 top will sort the processes according to cpu usage, update the output at 5 second intervals, and limit the display to the top 20 processes. I.e., this is a more manageable top. :) |
Quote:
I typed in locate trial.gif it didn't do anything... I tried with quotation marks too. This would be a handy find shortcut if I could figure it out. |
Even more basic:
Some simple commands-- ls will display a list of files and folders in the current directory. man followed by a command name will give you the online documentation for that command, including command line options. cal displays a calendar of the current month. (Just for fun, type cal 9 1752 which will show you September of 1752. Notice anything?) As someone else noted on a different message topic, you can open GUI applications with the open command followed by the full path of the application. Ex. open /Applications/TextEdit.app will open (ta-da!) TextEdit. who will list all the people logged into your computer. You should at least see your own ID, plus anyone who's remotely logged in. There are more, of course, but dig through the man pages and just about any directory named bin (like /usr/bin, /bin, /sbin or /usr/sbin) and you'll find some others. One last one: /sbin/ifconfig -a will display all of your networking settings for all active network interfaces. Well, one more... /usr/sbin/netstat -a will dump out your active network connections. (Once again, I'd recommend using the man command to look up more info on these and other commands.) |
>>Is there a trick to this? I opened terminal, got the Welcome to Darwin! [localhost:~] mcnallyd%
I typed in locate trial.gif it didn't do anything... I tried with quotation marks too. This would be a handy find shortcut if I could figure it out. Yes, there is a trick. locate uses a database to find files, which is why it's so fast. In order to update the database, you need to run this periodically: sudo /usr/libexec/locate.updatedb It's kind of like the way Sherlock indexes your files for Find By Content. |
My fav obscure commands are:
sudo fs_usage to see what apps are writing to the drive at any giving time. and: fink --help (needs fink installed) apropos command (where "command" is something you want to learn about) try: apropos rm and then type man "command" where "command" is one of the listed unix commands you don't understand. Digging into the man pages is the best way to learn unix. If you don't do this, you will forever be asking questions on forums instead of answering them. Y |
finding information
The first command I tell people about is:
man -k WHATEVER IE. if you were interested in calendars, try: % man -k calen WMCALCLOCK(1) - Dockable Calendar Clock cal(1) - displays a calendar calendar(1) - reminder service some things spit out a lot of info on a lot of commands, but you would be suprised at the new commands you learn! Cheers, Doug |
About the ls command...
Some useful flags:
-a List all files, including any dot files -F Indicate file types: / = directory, * = executable -m Show files as a comma-separated list -s Show size of files, in blocks (typically, 1 b;ock = 1,024 bytes) -C Force multiple column output on listings. -1 Force single column output on listings You can combine flags: ls -aF or ls -s -F Try some combinations and see what you get... Cheers... |
Regarding locate: must initialize database first
locate works by updating a database every week or day and simply looking for the file in there instead of actually looking for the file all over your hard disk. However, the database is not always up to date. By default, the database is updated every week (I think) using the command locate.updatedb but you can change it so that it is updated every day instead. There is a program that makes use of locate to find files it is called Xlocate.
Anyway, if it does not find what you want, you can always initialize the database manually with: sudo /usr/libexec/locate.updatedb in the Terminal. |
Another Newbie joins the Fun!
It seems to me that there are a multitude of commands available, and each of them seems to have a multitude of options.... so....
1. How do you remember them all! (especially if you are not using them every day! 2. Is it possible to use both Terminal and OSX GUI at the same time? i.e. by opening Terminal and typing the sudo su command to gain root access, can you then delete files in the Finder within OSX GUI that are only possible to delete as root? (If so, how? I can't seem to be able to do this!) :mad: |
it's going to be handy to pick up a *nix book of some sort. I'm a complete newbie myself, but the O'REILLY "Linux in a nutshell" has a huge list of commands listed in it. I'm sure something for OSX might be out, but I've had this book for about 2 years, when i dabbled a little in linux. All the commands seem to work, for the most part.
keeping at least one reference handy is going to make the whole experience go a lot easier. You will be glad that you picked one up.. (you could even go for an out of date linux book or something like that. spend $9 instead of $24. the commands will still be the same) |
Books...
I keep "Unix in a Nutshell" by Arnold Robbins (O'Reilly) and "Teach Yourself Unix in 24 Hours" by Dave Taylor (Sams) on my desk at all times.
I recommend both of them... Cheers, |
Remembering commands
One easy way to remember a frequently used but archaic command is to create an alias. Below are the instructions (plus some very common Unix commands you should be familiar with).
First you will need to make some one time preperations (if you haven't already). Create a directory for holding your customizations by using mkdir (make directory)... mkdir ~/Library/init mkdir ~/Library/init/tcsh Sure you could create these folders in the Finder, but this forum is about getting familiar with Unix, right? Now, change to the directory you just created using cd (change directory)... cd ~/Library/init/tcsh You should now be in the directory Users/(username)/Library/init/tcsh. To make sure, you can use the pwd (print working directory command)... pwd Now create a file to hold your aliases. The file must be called aliases.mine and you create it easily using a Unix text editor called pico. While in the ~/Library/init/tcsh directory, type the following command... pico aliases.mine Now you are in the pico editing window. We will setup an alias called topcpu to easily access one of the commands suggested in this thread. (allowing you to view the name of up to 15 running applications sorted by CPU usage) While in the pico editing window, type the following... alias topcpu 'top -u -s1 15' The spaces between the first and second part of the command are just a single tab. Also, make sure that you hit return after typing the above line. To save the file, hit ctrl-x (not cmd-x!!). It should prompt you to save the file as aliases.mine so just hit return. Any future aliases can just be added to this same file (by placing each on its own line). Now close the terminal window (this causes the terminal to check for new commands). You could also type rehash to do the same, but I usually just close the terminal window and open a new one. That's it. To run the previously hard to remember, but very useful, command top -u -s1 15, all you have to do now is simply type the name of your alias at the prompt... topcpu You can also create your own executables using a similar technique (helpful for when you want to employ mutiple complex commands using a single one word command). For instance, I created one called "trash" that forcefully deletes those stubborn files that refuse to go away. It automatically clears several possible flags and using root permissions it force deletes everything in the trash. No danger of mistyping an archaic commands (after the first time setup!). I just type the word trash and my trash is empty. But that's a lesson for another day (if anyone is interested). |
Reply to Maclaw
Thanks for a very clear, precise and informative post. I followed all of that to the letter... and it worked for me!
Wow this stuff is really going to keep me up late! |
ManOpen
Also, for those who like to peruse man pages there's a little app called ManOpen which might be a little more convenient than using Terminal for the purpose.
|
Quote:
Quote:
|
You probably know if you're using Fink that to find out what package a particular file is part you can use the command:
dpkg -S Now, I'm using quite a lot, a "new package" ported to Fink by Ben Hines: "dlocate" - is a "fast" alternative to dpkg for queries like `dpkg -L' and `dpkg -S' It uses GNU locate to greatly speed up finding out which package a file belongs to (i.e. a very fast!! dpkg -S). And many other uses, including options to view all files in a package, calculate disk space used, view and check md5sums, list man pages, etc. Adds a cron.daily script, used to update the locate daily as part of your cron tasks. I love it, it saves me a lot of time :) Code:
Sao @ ~ $ dlocate -S fncychap.styCode:
Sao @ ~ $ dlocate dillo |
| All times are GMT -5. The time now is 10:12 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.