LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2007, 08:11 PM   #1
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Rep: Reputation: 0
Newbie homework assignment


I hate that this is going to be my first post but, I'm really lost on this very basic assignment. I'm command line challenged and would appreciate any help you Linux pro's could give me on this.

1.Boot into Linux and log in as root. Easy enough, did that.


2.Create a directory called /backup. Change directory to /backup. Easy enough, did that.


3.Create three files in the /backup directory called file1.txt, file2.txt, and file3.txt. Enter some text into each file. Embarrassing as it is, how do you create a new file in command line? I have Emacs and Vim as available editors.


4.Mount a USB memory stick or floppy diskette.???


5.Enter the following commands to archive the three files you have created:

tar available /mnt/X/backup.tar .

Where X is the subdirectory under /mnt where your persistent storage is mounted

6.Delete the three files from the /backup directory.

7.Copy backup.tar from your persistent storage device to the /backup directory.

8.List the contents of backup.tar using the following command. Enter the result below.

tar tvf backup.tar

________________________________________________________________________

9.Use vi to view the contents of the file. What do you see?

________________________________________________________________________

10.Restore the files to the /backup directory using the following command.

tar xvf backup.tar


Have the files been restored to their original form?
 
Old 11-13-2007, 09:07 PM   #2
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Created the files but, can't find them.

How do I find the files and move them to the backup dir?
 
Old 11-13-2007, 09:24 PM   #3
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
Quote:
Originally Posted by longs_peak2002 View Post
3.Create three files in the /backup directory called file1.txt, file2.txt, and file3.txt. Enter some text into each file. Embarrassing as it is, how do you create a new file in command line? I have Emacs and Vim as available editors.
I prefer pico and would enter "pico file1.txt" on the command line then type "This is file one." then save the file.
Quote:
Originally Posted by longs_peak2002 View Post
4.Mount a USB memory stick or floppy diskette.???
Which do you need to use (and on what distribution)? In Debian a simple "mount /floppy" will mount a floppy disk. A USB drive is slightly harder.

Check "man tar" for how to use it. For instance "tar xvzf filename" is a common command to untar source code.
 
Old 11-13-2007, 09:31 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Ad 3:
touch will create an empty file; further any editor can create files from scratch
for vi:
vi filename
press <i> to go to insert mode
type some text
press <esc> to go back to command mode
press <:>
type wq and press <enter>

I don't know if the rest is already questions; there were no coloured markings so I assume you want to try that yourself first or don't have problems with those.

I don't quite understand post #2. Usually find <path> -name <filename> -print will find files for you in the current directory and subdirectories; replace the stuff between '<' and '>' by what you need. You can look at the -exec option of find to process the results (move in your case).

Last edited by Wim Sturkenboom; 11-13-2007 at 09:34 PM.
 
Old 11-13-2007, 10:02 PM   #5
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Can't use pico. I'm working off of a Knoppix CD that uses Vim or Emacs.

From "root@ttyp1[knoppix]#" I typed "ls" and got the following:

Desktop backup file1.txt file2.txt file3.txt office tmp

I'm assuming that my (3)files are on the desktop? How do I move them to the backup dir?

From there, i need to mount a USB drive and move them there.

Thanks for the quick response guys, it's been helpful so far.
 
Old 11-13-2007, 10:20 PM   #6
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
I booted Knoppix 5.0.
Calling "pico" actually calls "nano" which is very similar. Personally I prefer pico, nano, or even joe (jpico) for simple text editing needs. Using any text editor is going to be the same. <name of editor> <name of file to open/create>.

As Wim Sturkenboom said, you can use the touch command to create an empty file, or even something like "echo This is file one > file1.txt". Try using the up-arrow key and making an edit to the command line to create the second file as "echo This is file two > file2.txt"

Is seems you have created the directory called backup. If you had used "cd" (to change directory) you could have created your files there. Now you can use "cp" or "mv". Check the man pages.

Are you using command line only to access the USB drive?

Last edited by 2damncommon; 11-13-2007 at 10:34 PM.
 
Old 11-13-2007, 10:34 PM   #7
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
I actually found joe on the CD! Cool.

Okay, I finally found the files and moved them to the backup dir, uding mv as you suggested. I typed, mv file1.txt backup. Then cd backup, then ls and found all three files.

How do i mount the USB drive now? I don't have to use command for this.
 
Old 11-13-2007, 10:45 PM   #8
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
Again I am on Knoppix 5.0 which could be slightly different if you are not using the same.

When I plug in my USB drive I choose "Open in New Window".

At this point you can open a couple GUI windows and drag and drop or type "mount" from your command line. Typing "mount" by itself will show the currently mounted devices. My USB drive is on /media/sda1. I can use the "cp" command to copy, or the "mv" command to move the files to /media/sd1. You will want to run your "tar" command, which puts your 3 files in one.

A simple way to view files is to use either "cat" (for short files) or "less" (for larger files. Again <command> <filename>.

Last edited by 2damncommon; 11-13-2007 at 10:47 PM.
 
Old 11-13-2007, 10:59 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
His instructions say he needs to use "vi" so suggesting another editor isn't helpful.

You might try running "vimtutor" to learn how to use "vim". You really only need to know how to get into the "insert" mode, enter your text; exit to the command mode; and save the file in order to complete the assignment. If you install linux, you will probably want to edit the /etc/sudoers file, and to do that you use visudo, so learning the vim basics is a good idea.

A quick way to create a simple text file is with cat.
cat >text1
this is a sample line
this is the second line
[CTRL]-d

Most of the basic commands you use in the shell are provided by the coreutils package. See if you have the "info coreutils" manual. The commands like "mv", "mkdir", "cat" and many others are described there.
 
Old 11-13-2007, 11:05 PM   #10
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
i attach the usb drive but don't get any "open in new window" option. Are you going somewhere else to do that? I don't see my drive listed under peripherals.
 
Old 11-13-2007, 11:11 PM   #11
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
Quote:
Originally Posted by jschiwal View Post
His instructions say he needs to use "vi" so suggesting another editor isn't helpful.
Since <editor> <file to open/create> is the same I made him work some. Since he further said he is using Knoppix I said what was available on mine. AFAIC the VI/EMACS thing is a tired old troll for simple text editing.
I intend to make him read man pages and try commands if he is asking me.
 
Old 11-13-2007, 11:12 PM   #12
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
Quote:
Originally Posted by longs_peak2002 View Post
i attach the usb drive but don't get any "open in new window" option. Are you going somewhere else to do that? I don't see my drive listed under peripherals.
Which version of Knoppix are you using?
 
Old 11-13-2007, 11:13 PM   #13
longs_peak2002
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
thanks guys, i'll read the man pages.
 
Old 11-13-2007, 11:19 PM   #14
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
Are you using Knoppix in command line only or as full GUI? The "mount" command should show the correct device name to use.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Homework pixellany LQ Suggestions & Feedback 14 06-30-2006 07:20 AM
help me with my homework assignment by filling in the blank nkoplm General 11 11-25-2005 10:57 AM
please help my homework again donotexpert Programming 7 08-23-2005 10:26 AM
help me(my homework) please! donotexpert Programming 4 08-20-2005 06:26 AM
Need homework help! bumstickie Linux - Newbie 3 10-28-2002 04:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration