Executing commands as root
Let's have some fun with root so you can see what root can do. We are going to be writing in a home account named user1
[root@server2 agustin]# cd /home/user1
Create a directory using: mkdir
[root@server2 user1]# mkdir collections
Change to directory collections
[root@server2 user1]#cd collections
[root@server2 collections]#
So far we created a directory called collections, we moved into it and now collections is our current working directory. You can send data to a file or device on the fly by using the echo command.
[root@server2 collections]#echo paste this information to a file <>
So how do you know the information has been sent to myfile
The cat command
[root@server2 collections]#cat myfile
paste this information to a file
[root@server2 collections]#
At this point, you should have a file in your collections directory, create another directory
[root@server2 collections]# mkdir onother
[root@server2 collections]#ls
afile file2 myfile onother/
[root@server2 collections]#
We can easily make a back up of a file inside our current directory; this is useful when you need to edit a file. For security reasons always backup a file when you need to edit it.
The copy command: cp
[root@server2 collections]#cp myfile original.myfile
[root@server2 collections]#
To view the content of a directory with details, we just add some switches to our ls command.
[root@server2 collections]#ls –l
total
-rw-r--r-- | 1 root | root | 6 Aug 17 | 09:09 afile |
-rw-r--r-- | 1 root | root | 27 Aug 17 | 09:46 file2 |
-rw-r-- r-- | 1 root | root | 14 Aug 17 | 09:46 myfile |
drwxr-xr-x | 2 root | root | 4096 Aug 17 | 10:34 another/ |
-rw-r—r-- | 1 root | root | 14 Aug 17 | 10:46 original.myfile |
[root@server2 collections]#
These parameters are useful when digging inside directories. There are many others that you may want to look at. –l –R –n – I –a –all
[root@server2 collections]#man ls
Use man ls to read the manual and look at all the switches available to the command. Use the up and down arrow to scroll the manual page and press “q” to exit the manual.
No comments:
Post a Comment