Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Must-have Terminal commands

Must-have Terminal commands
Thread Tools
andreas_g4
Professional Poster
Join Date: Mar 2002
Location: adequate, thanks.
Status: Offline
Reply With Quote
May 28, 2006, 02:57 PM
 
I was just configuring my MacBook when I thought that I really have too less knowledge about what can be achieved with the Terminal.

I know there are several cleaning/maintenance routines that can/should be performed from time to time via the Terminal somethink with daily/weekly etc.).

Then I know that command to make the Terminal transparent, which just looks cool: defaults write com.apple.Terminal TerminalOpaqueness [value]

Then I knew that command to check battery capacity, but that one doesn't work with my MacBook anymore… ioreg -l | grep -i IOBatteryInfo

What commands are you using on a regual basis that you have found to be usefull? I know they are scattered all over the forum and the internet, but a dedicated thread wouldn't be harmful, I guess.

EDIT: I honestly didn't know about the UNIX forum…
( Last edited by andreas_g4; May 28, 2006 at 04:30 PM. )
     
chris v
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
May 28, 2006, 04:16 PM
 
kill.
sudo shutown -r now.
w.
ssh.
top.

I'm not a big CLI guy, but those come in handy all the time.

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 28, 2006, 05:22 PM
 
Now that Finder searching is all Spotlight, all the time, I find myself using find and locate a lot more.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Gavin
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
May 28, 2006, 05:30 PM
 
I use a few things all the time

mv to move files around
cp to copy files

- used with sudo you can handle files among multiple users

ls -l to list a folder's contents

cat to look at the contents

| (vertical bar) will take the results of one command and "pipe" them into another

so
cat filename | less
gives you a way to read a file and scroll up and down

head and tail will give you the beginning and end of a file - useful for looking at log files

tar, gzip, gunzip, bzip and bunzip for compression and archiving

top will show you what is running and memory usage in real time (more or less) - hit q to quit
ps ax gives you a list of processes

ifconfig - shows the network interface settings

en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULT ICAST> mtu 1500
inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255

this tells me my IP Address is 192.168.1.100

ll /var/log
tail /var/log/system.log
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 28, 2006, 06:06 PM
 
You can just use less filename to read a file.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
cybergoober
Mac Elite
Join Date: Jun 2003
Location: Newport News, VA USA
Status: Offline
Reply With Quote
May 28, 2006, 08:12 PM
 
FYI - Terminal transparency can be set directly in Terminal's Window Settings (Terminal menu -> Window Settings... -> select Color from the drop-down menu) now - since Panther, I think.
     
cybergoober
Mac Elite
Join Date: Jun 2003
Location: Newport News, VA USA
Status: Offline
Reply With Quote
May 28, 2006, 08:16 PM
 
Originally Posted by Chuckit
You can just use less filename to read a file.
You can also use zless and zmore to read compressed files (like the log files in /var/log that end in .gz) without un-archiving them first.
     
barney ntd
Dedicated MacNNer
Join Date: Dec 2001
Location: Bolton, UK
Status: Offline
Reply With Quote
May 29, 2006, 07:28 PM
 
In Tiger, you don't need to run the maintenance scripts from the terminal. They are run automatically by launchd.
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
May 30, 2006, 11:26 PM
 
Originally Posted by andreas_g4
Then I know that command to make the Terminal transparent, which just looks cool: defaults write com.apple.Terminal TerminalOpaqueness [value]
You can also just use the Window Settings menu item... (look under the Color options).

-Scott

EDIT: Doh! I just saw that someone already posted that. I really did look at the posts first. It's late, I'm tired, etc... OK, to make up for it, check this site for lot's of good tips:

http://www.cs.cmu.edu/~benhdj/Mac/unix.html
Scott Genevish
scott AT genevish DOT org
     
Juggle5
Junior Member
Join Date: Nov 2001
Location: Seattle
Status: Offline
Reply With Quote
May 31, 2006, 12:43 AM
 
More useful commands:

grep -- search through files
open -- open something as if you had double clicked it
curl -- for downloading stuff
cal -- displays a calendar
uptime -- shows how long your computer has been running
man -- gives syntax/usage for commands

vi/vim -- for editing text files (great after you get past the steep learning curve)
pico -- good for quick edits if you don't want to learn vi
gcc/g++ -- compile your own programs!
     
whgoodman
Junior Member
Join Date: Jun 2005
Status: Offline
Reply With Quote
May 31, 2006, 07:33 PM
 
find - find files by permissions, owner, group, etc. very useful if you want to remove a certain type of file on your system. i.e. find / -name core -exec rm {} \; will remove all of the core files from your system
df - display disk utilization by mounted disk. df -k will display in KB the total and used space of mounted file systems.
du - very useful to find the files eating up your disk space. du -sk * in any given directory will give you the amount of space in kb each file takes. In the event of a directory, it will traverse the file structure and tell you the total space of all files beneath the directory.
     
exca1ibur
Mac Elite
Join Date: Oct 2000
Location: Oakland, CA
Status: Offline
Reply With Quote
Jun 3, 2006, 06:35 AM
 
For me...

alias (custom profile commands)
ls -la -G (my alias for ls)
grep
vi
man
curl
ssh
sudo
> (i.e. ls > filename) Save as a text file
     
alphasubzero949
Mac Elite
Join Date: Jan 2003
Location: 127.0.0.1
Status: Offline
Reply With Quote
Jun 5, 2006, 08:05 PM
 
Check out CLIX. There are many, many different CLIX databases for just about everything you could think of. You can even add your own commands.

That said, my favorite is...

sudo find / \( -name *.lproj -and \! \( -name English.lproj -or -name en.lproj \) \) -exec rm -rf \{\} \;
     
Cipher13
Registered User
Join Date: Apr 2000
Status: Offline
Reply With Quote
Jun 5, 2006, 10:29 PM
 
My most used commands off the top of my head:

locate
ssh
scp
uptime
top
ps
ifconfig
clear
less
grep
awk
curl/wget
nano
ls/mv/cp/rm/cd
     
Rob van dam
Grizzled Veteran
Join Date: Oct 2001
Location: Australia
Status: Offline
Reply With Quote
Jun 25, 2006, 01:31 AM
 
Can someone kindly provide me the terminal commands for performing the crons.I want to peform them for maintence since i got rid of the app that does this.
( Last edited by Rob van dam; Jun 25, 2006 at 01:49 AM. )
Apple an innovator in a world of Immitators.
And thats the bottom line!!!!!!!!!
     
MiniMoe
Fresh-Faced Recruit
Join Date: Jun 2006
Status: Offline
Reply With Quote
Jun 25, 2006, 07:03 AM
 
You mean

sudo periodic daily (or weekly or monthly) ?
Moe
1.66GHz Core-Duo Mini, 2GB/120GB, Apple 23" Cinema HD Display
Apple Wireless Keyboard & Mouse, Apple iSight Camera
Apple USB Modem (for faxing), Bose Companion 2 Speakers
2.0GHz white MacBook 1GB/80GB
     
Rob van dam
Grizzled Veteran
Join Date: Oct 2001
Location: Australia
Status: Offline
Reply With Quote
Jun 25, 2006, 07:13 AM
 
Originally Posted by MiniMoe
You mean

sudo periodic daily (or weekly or monthly) ?

Its something along those lines.Im still not sure if tiger does it on its on.I just want to enter it manually and do this periodically.
Apple an innovator in a world of Immitators.
And thats the bottom line!!!!!!!!!
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Jun 25, 2006, 09:03 AM
 
The OS does cron automatically, and Tiger does not miss the schedule due to sleep or shutdown.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 25, 2006, 01:00 PM
 
rsync
scp
wget (you can install this over DarwinPorts)
ClusterSSH is a very cool app
     
danengel
Mac Enthusiast
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jun 28, 2006, 05:04 PM
 
"screen" for having multiple crash-safe terminals in one window
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:14 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,