Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

Learning UNIX on my own.

I need some major help here ... I dont know where to even begin on this example.
Create a file with the following lines (where the ? is replaced with the appropriate information):

My PC is running: kernel ? release ?
My account is on file system ?
The available space on my file system is ?
The directories for this course are using ? of disk space.
The type of this file is ?
This system has been running for ? days ? min.
My uid is ?
I belong to group(s) ?
Append to this file your search path
Append to this file a line of  40 dashes
Change your command prompt and append the new setting to this file

I started with the following but not even sure if it is correct.

echo "My PC is running: kernel" `uname -s' "release" `uname -r`
echo "My account is on file system" `df -T, --print-type`
echo "The available space on my file system is" `df -h`  (df ~username)
echo "The directories for this course are using" `du` "of disk space"
echo "The type of this file is" `file`
echo "This system has been running for" `uptime`
echo "My uid is" `id`
echo "I belong to group(s)" `id -a`
0
Cyber IT
Asked:
Cyber IT
  • 4
  • 4
  • 2
  • +2
3 Solutions
 
ozoCommented:
echo "My PC is running: kernel" `uname -s' "release" `uname -r`
should probably be
echo "My PC is running: kernel" `uname -s` "release" `uname -r`
0
 
Cyber ITEngineerAuthor Commented:
i dont see the difference
0
 
Duncan RoeSoftware DeveloperCommented:
Nowadays $() is a replacement for backtick and allows you to write simpler-looking code. Also $() nests - no need to use intermediary variables.
***Also, you don't confuse backtick with single-quote as you did in "echo "My PC is running: kernel" `uname -s' "release" `uname -r`" (look carefully after -s:)
Either way, you can surround everything in a single pair of double quotes.

When df--help reports:

  -T, --print-type      print filesystem type

that means you can use -T *or* --print-type, not both.
To restrict df to only print output regarding your working directory, give it a directory argument of the current directory ".".
In the example, my home shows as type "none" - yours won't do that though. /sda2/home is mounted --bind (you'll learn about that later - not the first thing you need to know about).
df will output a heading line which you don't really want - I suppressed that with the "tail" command.
To read about the tail command, type "man tail". Similarly for any other command.

See how you go with the rest - post again if stuck. Good luck with your endeavours!
echo "My PC is running: kernel $(uname -s) release $(uname -r)"
echo "My PC is running: kernel `uname -s` release `uname -r`"
 
df -T .
 
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/sda2/home    none   187785588  75979452 102267144  43% /home
 
 
07:35:32$ echo "My account is on file system $(df -T .)"
My account is on file system Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/sda2/home    none   187785588  75979452 102267144  43% /home
07:41:41$ echo "My account is on file system $(df -T . | tail -1)"
My account is on file system /sda2/home    none   187785588  75979452 102267144  43% /home

Open in new window

0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
ozoCommented:
the difference is a ` (ASCII 0x60) where you have a ' (ASCII 0x27)
0
 
ai_ja_naiCommented:
It's an EE policy not to do students' homeworks. If you need help on a specific matter, please ask. But don't ask for generic excercises' solutions.
0
 
Duncan RoeSoftware DeveloperCommented:
He did say he was learning on his own - I assumed that precluded it's being homework
0
 
Cyber ITEngineerAuthor Commented:
This is actually not homework and I understand your policy.
0
 
Cyber ITEngineerAuthor Commented:
ozo:
Sorry I see it now. I meant to put `.
0
 
joolsCommented:
for the `df -T . ` to report the correct information you should be in your home directory so you may need to make sure you are there first by adding a `cd ` before the command.

for the last bits you may want to use echo ... >> or cat ... >> to append.
Have a look at the man page for bash...

Just a thought...
0
 
Duncan RoeSoftware DeveloperCommented:
You can do "df -t ~" to ensure you refer to your home directory. In bash, ~ means your home, ~fred is fred's home, ~root is root's home, and so on.
0
 
Duncan RoeSoftware DeveloperCommented:
I meant "df -T ~"
0
 
joolsCommented:
Even better, nice tip duncan!
0
 
Cyber ITEngineerAuthor Commented:
Thanks ...
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now