Help with Terminal commands

cevin

Registered
Hi I would like to learn wich commands to type in the terminal to:

  • [*]Manually run Cron scripts.
    [*]enable or disabel jounaling (Jounaling File System).
    [*]repair file and folder permissions.
    [*]create symbolic links.
    [*]delete locked or unaccessible items.
    [*]uppdate prebinding information.
    [*]force empty trash.
thanx,
cevin
 
The only ones I remember in 2 seconds..

Force empty trash:
rm -rf ~/.Trash/*
OR
sudo rm -rf ~/.Trash/*

Update probinding etc:
sudo update_prebinding -root /

Delete
rm
 
You can manually run cron scripts by using:

sudo periodic daily
sudo periodic weekly
sudo periodic monthly

For repairing permissions, you need the chmod and possibly the chown command.

chmod 750 filename

(Gives the owner of the file all access, the group Read & Execute, and everybody else no access)

chmod is a complex command. It can be used in a numeric mode, like this:

chmod 740 file

The first digit '7' represents the OWNER of the file.
The second digit '4' represents the file's GROUP.
And the third digit represents ALL OTHER USERS.
Basically, you use 4 for read access, 2 for write access, and 1 for execute access, and simply add them together. So to give others read and execute access to a file, you'd add 4 and 1 to get 5, so the last digit is 5.

The other way of using chmod is using letters like these:
chmod a+x file

u - User (owner)
g - group
o - Other
a - All

... then, a plus or minus to allow or disallow the privilege, then ...

r - Read
w - Write
x - eXecute

So, for example:

chmod g+w file (Give the group write access to the file)

chmod o-rwx file (Take all privs away from other users who aren't the owner or group)

You'll have to do some more reading, depending on what you want to achieve.
 
oh, one more thing. How do you make scripts to run with the terminal. I've sean people run those on ADC TV but not how to make em.

And If anyone could tell how to create symbolic links with the terminal would be greate too. I want to move folders like documents and pictures to another Volume. This desn't work great with Alias but I've heard that symbolic links does.

thanx,
cevin
 
cevin,

First you need to learn a scripting language, there are many. The shell that your terminal is running provides one. On my machine at least I'm using /bin/tcsh. Perl is another scripting language.

Basically you do this:

1) create a file, this file starts with an indicator of what shell to execute this file with. For instance, a perl script would start with:

#!/usr/bin/perl

After this all of the code necessary to complete your task would follow.

2) Turn on the executable permissions for your file:

chmod u+x filename

3) execute the file

./filename

or /full/path/filename

For example you can cut and paste the following code and place it in a file called demo.pl, chmod u+x demo.pl and then execute it with "./demo.pl demo.pl". All it does is reverse the contents of a file from top to bottom.

#!/usr/bin/perl

use strict;

print reverse <>;
 
cevin--These links will probably be helpful to you if you would like to do some basic reading on OS X's UNIX underpinnings:

O'Reilly's MacDevCenter Terminal.app primer
(should probably be the first thing you read):
http://www.macdevcenter.com/pub/a/mac/collections/unix.html

The OS X FAQ Learning UNIX Center
(a very good resource and introduction to the UNIX side of OS X):
http://osxfaq.com/Tutorials/LearningCenter/

An introduction to Permissions
http://osxfaq.com/Tutorials/LearningCenter/UnixTutorials/ManagingPermissions/index.ws
http://osxfaq.com/Tutorials/LearningCenter/AdvancedUnix/ugp/
http://osxfaq.com/Tutorials/LearningCenter/AdvancedUnix/ugp2/
 
You can verify disks and permissions from the command line with diskutil:
sudo diskutil verifyPermissions /
sudo diskutil repairPermissions /


You can also use it to check and repair disks:
sudo diskutil verifyDisk /Volumes/non-bootdisk
sudo diskutil repairDisk /Volumes/non-bootdisk

You cannot verify or repair / (the boot volume), since it is in use and not-unmountable. You have to boot into single user mode or off of a CD in order to verify or repair that disk.
 
Again diskutil is the utility of choice:
sudo sudo diskutil enableJournal /
sudo diskutil disableJournal /

or for a non-boot volume:
sudo diskutil enableJournal /Volumes/volumename
sudo diskutil disableJournal /Volumes/volumename
 
The basic syntax is: ln -s source-file target-file
(sometimes you will need to use it in conjunction with sudo, depending on the location of the symbolic link. Also, don't forget to specify the path to the file also).

You will find that these commands are your friends:
which
whatis
man

(telling you where a command line tool lives, what it does, and an in-depth manual usually with examples)

man ln, for example.
 
Back
Top