Exercise 1.4.1 File & Directory operations
Open a terminal and write down which commands you use to:
- We use the command 'pwd' (print name of working directory)
Get a list of all files and folders in the current folder:
- We use 'ls'
Change directory to /home/stud:
- We use ' cd /home/stud'
Create a directory /home/stud/test:
- We use 'mkdir /home/stud/test'
Change directory to the subdirectory /home/stud/test:
- 'cd /home/stud/test'
Create a file text1 containing hello there using kate:
- We use 'kate -n' and saves as text1
Create a file text2 containing hello there using echo:
- We use 'echo hello there > text2'
Append 1234567890 to file text1 using echo:
- We write 'echo 1234567890 >> text1'
Dump the contents of text1 to the terminal window:
- We write 'cat text1'
Copy text1 to the directory /tmp:
- We write 'cp text1 ../tmp'
Delete text1 and text2 in one go:
- We use 'rm "text1" "text2"
Delete the directory /home/stud/test:
- We use 'rmdir test'
Exercise 1.4.2 Program control
Run program the kate in the background:- We use 'kate&'
Now kill the program kate you just started:
- We write 'pkill kate'
Write a small shell script that lists the current directory. Remember to make you shell
script executable using the program chmod.
1. chmod command:
- We write 'chmod +x <filename>'
2. Shell script:
#!/bin/bash
ls
Exercise 1.4.3 Acquiring system information
Get a list of the currently running processes (programs):- We use 'top'
Display the current date and time in the terminal:
- We use 'date'
Find the IP address of the network adapter eth0:
- We write 'ip addr show eth0'
Explain what the /var/log/syslog does:
- It makes a log for what your system does
Try using running less /var/log/syslog and read the manual for less. What is it
good for?
- It shows the most important things from the log
What happens when you run dmesg?:
- It prints the message buffer of the kernel. Is used to examine the kernel buffer.
Extending the above like this dmesg|less, what does | do?:
- It allows the output to be moved forward one screenful at a time by pressing the SPACE bar, backward by pressing the b key and removed by pressing the q key.
Determine the CPU type by looking the directory /proc:
- Write 'less /proc/cpuinfo'
There is a lot of system information to find in /proc, mention at least 3 different files and
what they tell you:
1. timer_list - Show how the timers works
2. uptime - Show how long time the system has been on, and how many users there is
3. version - Show the version of Linux
We have chosen to give You 75% correct. The reasen for this is that we have found 4 wrong answers and 3 answers You need to be aware of (if using).
SvarSletFurther more we have found it overall deficient, due to lack of explanations (command-of-choice, abbrevations etc.).
Your 4 incorrect answers are:
"copy text1 to the directory /tmp" - what You have written copies the file and saves this in the parent directory with the name tmp.
"delete text1 and text2 in one go" - what You have written does not comply. Quotationmarks is only used if the filename contains spacing.
"[...] what does | do?" - You have not described what '|'(pipe) does, but what 'less' does.
"[...] what is it (less) good for?" - 'less' does not only display the most important things in a file.
You need to be aware of following answers:
"delete the directory [...]" - You can not remove the directory unless it is empty (it is possible, but with another command).
"now kill the program kate [...]" - using 'pkill kate' kills all instances of kate, this may not always be desired.
"[...] list of currently runnning processes" - 'top' displays repitive list of tasks, not processes.
In stead of 'top' You could use 'ps' for a simple list with user-opened processes or 'ps -A' for a full list.
Regards group 14
11442 - Jon Grove
11490 - Peter Mathiesen
11533 - René Sørensen
Further more you need a more thorough explanation of the script-exercise. We do not believe this will be sufficient if you read it in a couple of years (without Linux experience).
SvarSletIt is 11553 NOT 11533!