Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.