Hi guys,
Hoping someone can help with the below - involves basic commands and some scripting. Thanks so much in advance for your amazing time and help.
- The file /
etc/profile
contains the default initialization options for your shell.
Produce a unique list of all variables with uppercase names that have been set
in/etc/profile
sorted in alphabetical order.
the output should be something like:
EUID
HISTCONTROL
HISTSIZE
HOSTNAME
LOGNAME
MAIL
PATH
UID
USER
- The file
/etc/passwd
contains lines that look like this:
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
The field delimiter is : and the fields are:
username:password:userid:groupid:realname:homedirectory:shell
Come up with a UNIX command that will find and print out the home directory of
the user whose username is 'root'.
-
Come up with a UNIX command that will print a sorted, unique list of all of
the different shells used by the different users in/etc/passwd
. -
Come up with a UNIX command that will print a list of usernames from
/etc/passwd
that end with a vowel. -
The '
env'
command prints out all of the environment variables and their values.
Come up with a command that prints a list of environment variables whose names
end with either'NAME', 'DIR' or 'PATH'.
-
Write a script called '
home.sh
' which takes a username as its argument and
will print out the home directory of that user as follows:
$ ./home.sh root
root's home directory is /root
$ ./home.sh nobody
nobody's home directory is /
If the command is used incorrectly, print a usage error to stderr:
$ ./home.sh
Usage: ./home.sh username
-
Write a script called big which takes a filepath as an argument. The script
should print "Big" if the file is more than 1000 bytes or "Small" if the file
is less than 1000 bytes. If exactly one argument was not given, print "Error"
to stderr. -
Using the metric system, where 1 kilobyte = 1000 bytes, write a script that
takes a filename as an argument and prints out the file size in kilobytes by
dividing the number of bytes by 1000.