In our last assignment you perform some basic task related to system administration from normal user. In this assignment we will extend this further. To complete this assignment login form our normal user Vinita.
Then what exactly this command did? As you know cat command is used to display the matter of file so it will first display the matter of first file and then it will display the matter of second file. But as you put a > sign at the end of command so despite of showing this output on screen command will redirect this matter to a file.
this command will first execute the first command which is cat new so it will display the matter of new file, further is mkdir xyz so it will create a xyz directory , further is mkdir rat so will create a rat directory and in the end we use ls command so it will list the contain of current directory.
$mv new first second xyz This command will move three files new, one, second to the xyz directory.
In linux you cannot restore the data once deleted unless you have backup. Now restore these files and directory.
To decompress file
$bzip2 –d manoj.bz2 $ls manoj as you can show file has been decompressed. Now use other utility to compress the file.
How to redirect the matter of files in a new file
Create two file and write some text in them.$cat > one This is first file $cat > second This is second fileNow we will combine these two files in a single file. In standard linux its call redirection of output.
$cat one second > new $cat new This is first file This is second files
How to execute multiple commands in a single row
$[command] ; [command] ; [command] ;[command]……..To execute multiple commands from single row use a ; between them form example
$cat new ; mkdir xyz ; mkdir rat ; ls This is first file This is second files new xyz rat
How to create multiple sub directory form single command
To create multiple sub directory from a single command use –p switch with mkdir command for example$mkdir –p a/b/c/d/f/g/h/i/jIn this example we created 9 subdirectories form a single mkdir command. Now verify it by listing.
$ls new xyz rat anow change the directory to verify the depth of directories.
$cd a/b/c/d/f/g/h/i/j $pwd /home/vinita/a/b/c/d/f/g/h/i/jCome back to home directory. Simple cd command without passing any argument will do this.
$cd
How to move multiple file in directory with a single commands?
Give all files name one by one with a single space between them and in the end give the destination directory name for example$mv new first second xyz
$cd xyz $ls New one second $cd ..
how to take back-up and restore files and directories.
tar command is used to take the back up with –cvf switches and the same tar command is used to restore the matter with –xvf switches. For example$tar –cvf backup.tar xyz $ls $rm –rf xyz
$tar –xvf backup.tar $ls $cd xyz $ls new first second $cd ..
How to compress files to save disk space?
Create a large file and check how much disk space is consumed by this file$man ls > manoj $du –h manoj 12k manojFile manoj is using 12k space on hard disk. For exam prospective you should familiar with two compress utilities.
$bzip2 [file name] {command syntax} $bzip2 manoj $ls $du -h manoj.bz2 4k manoj.bz2
$bzip2 –d manoj.bz2 $ls manoj as you can show file has been decompressed. Now use other utility to compress the file.
$gzip manoj $ls manoj.gz $du –h manoj.gz 4k manoj.gz $gzip –d manoj.gz $ls manoj
0 comments:
Post a Comment