Unix Shell and Properties
Whenever a user wants to run a program they can open a general purpose shell window and run the program under this shell.
For example a user using the Bash shell wanting to switch to csh (C shell) due to being more familiar with it can do so using the following command:
1 2 3 |
$ /bin/csh -- For temporary csh use, when finished with the c shell % exit |
Use > or >> to write the output of the command to a file.
Example: Running the following code, while in a folder, creates a file that has the same name as the folder’s processes. The contents of the file would be the output of the ps auxw command.
There wouldn’t be any output onto the screen as the entire output would be written to the file.
1 |
<strong>1</strong>- $ ps auxw > processes |
After logging on to the system, the shell automatically defines a folder’s environmental variables.
The list of environmental variables can be output using the printenv command: $printenv
Auditing accesses to files and folders
The chown folder is useful for changing the folder’s ownership. The following code can be used to change the ownership.
1 2 3 4 |
ls -l bsd.c -rw-r--r-- 1 bdd staff 20911 Jan 22 01:21 bsd.c chown burak bsd.c -rw-r--r-- 1 burak staff 20911 Jan 22 01:21 bsd.c |
chgrp can be used to change the group that a user is connected to. The following code can be used to achieve this.
1 2 3 4 |
# ls -l bsd.c -rw-r--r-- 1 bdd staff 20911 Jan 22 01:21 bsd.c # chgrp users bsd.c -rw-r--r-- 1 bdd users 20911 Jan 22 01:21 bsd.c |
* Using a chmod program to give a u+s privilege identifier before granting a program a SUID (set user ID) privilege.
1 2 |
# chmod u+s /bin/bash -rwsr-xr-x 1 root root 512540 Aug 22 19:46 /bin/bash |
In a way similar to SUID, it might be necessary to grant some programs temporary user group membership in order to run them.
An example of this is some software related to printer services requiring this.
Using the chmod program to grant a g+s privilege identifier before granting a SGID (set group ID) privilege.
1 |
chmod g+s /bin/bash |
Defining a link.
1 |
ln /reports/january-sales.txt /best-sellers/2001-january.txt |
The above code defines an alternative access route for a file using /reports/january-sales.txt, called /best-sellers/2001-january.txt.
After applying the above definition, even if one of these file names is deleted the file will remain accessible until the other filename has been deleted. However deletion of the last hard-link will result in the file being linked to also being deleted.
-rwxr-sr-x 1 root root 512540 Aug 22 19:46 /bin/bash
The following code defines a hard-link to a file named php.ps:
1 2 3 4 5 6 7 8 |
# ls -l total 239 -rw-r--r-- 1 root root 242783 Dec 13 10:50 php.ps # ln php.ps php-document.ps # ls -l total 478 -rw-r--r-- 2 root root 242783 Dec 13 10:50 php-document.ps -rw-r--r-- 2 root root 242783 Dec 13 10:50 php.ps |
Soft-links are a type of link file that can be defined by any system user and are easier to understand and manage. They also allow access to a present file through a variety of routes.
The difference between soft and hard links is: when a soft-link is deleted the original file remains and if the original file is deleted, the soft-link remains but doesn’t point to anything.
A soft-link can be created by using the -s parameter as shown in first line of the following example:
1 2 3 4 |
$ ln -s /reports/january-sales.txt /best-sellers/2001-january.txt $ rm /reports/january-sales.txt $ cat /best-sellers/2001-ocak.txt No Such File or Directory |
Oracle Recovery Manager...
12 March 2019