LinuxQuestions.org
Review your favorite Linux distribution.
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 10-27-2009, 10:09 AM   #1
systemshock869
LQ Newbie
 
Registered: Oct 2009
Posts: 4

Rep: Reputation: 0
Basic text editing in command line environment


Hi I am about to attempt to add some code to my xorg.conf file, which requires that I log out and shut down X. I have the code saved in a text file in my /home directory, but I really have no idea how I am going to copy that code and insert it into a certain space in the xorg.conf file. Any help would be appreciated!

It appears that the only text editors I have (that i've found) are vi and geany.
 
Old 10-27-2009, 10:18 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
One (relatively easy) approach with "vi":

1. Save the text you want to a temp file:
Quote:
<esc>:w /tmp/tmp.txt
2. Open your file:
Quote:
vi myfile.txt
3. Scroll down to the part you want to "insert", and read in your temp file:
Quote:
<esc>:r /tmp/tmp.txt
 
Old 10-27-2009, 10:27 AM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 7,263

Rep: Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358
I'm not sure I understand what you want to do. If you have a file in your home directory with info you want to use to copy with vi you can open the file in your home directory:

cat /home/user/myfile

should open the file. Open vi in another terminal to xorg.

vi /etc/xorg.conf

to insert into the xorg, hit the 'i' key on your keyboard, type the info where you want and when finished, hit the ESC key, type :wq to quit and save.

Not sure this is what you need?
 
Old 10-27-2009, 10:51 AM   #4
systemshock869
LQ Newbie
 
Registered: Oct 2009
Posts: 4

Original Poster
Rep: Reputation: 0
I was under the impression that to edit the xorg.conf file, you had to be logged out of the system and in a command line environment, as per these instructions.

Thanks for your quick replies! paulsm4, that helped alot. However, The info I needed to paste was already in the file! So I'm going to have to dig deeper I guess.
 
Old 10-27-2009, 07:23 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
Here's a nice cheat sheet for vi/vim http://www.tuxfiles.org/linuxhelp/vimcheat.html
 
Old 10-28-2009, 02:55 PM   #6
systemshock869
LQ Newbie
 
Registered: Oct 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Bookmarked! Thanks man
 
Old 10-28-2009, 04:43 PM   #7
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,093

Rep: Reputation: 197Reputation: 197
vi(m) is very powerful and most certainly worth learning to use, I'm surprised to see someone describe it's use as 'relatively easy' to someone who's experience is such that they have to ask the question you did. In terms of pick up and use friendliness I've always considered it akin to being repeatedly poking in the eye. It's the modal nature that confuses people most I think.

You don't say which distro you're using but Ubuntu has pico installed by default. Unlike vi it's not modal and it gives you a list of commands plus key combos on visible at all times.

Code:
$ pico filename
If you want to be editing a file quickly to fix something that's broken I think you'll find pico less stressful than vi. Save learning vi to do at your leisure.
 
Old 10-28-2009, 05:30 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
If there's something that linux has, it's text editors.

Vim has been suggested, and it's a good editor, though certainly it's neither the simplest nor for everyone. Though you can certainly learn just a few commands in five minutes of course.

In my book, "simple" has another meaning. Simple editors (text mode) are pico, nano, mcedit, joe... there are many more.
 
Old 10-28-2009, 05:31 PM   #9
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
duplicated
 
Old 10-28-2009, 06:46 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by systemshock869 View Post
I was under the impression that to edit the xorg.conf file, you had to be logged out of the system and in a command line environment, .
Not true, you can edit xorg.conf at anytime, and then simply restart X (required for the changes to be effective). ctrl-alt-backspace often does this, or you can open a terminal, su to root, and enter "init 1". To restart X, "init 5"
 
Old 10-28-2009, 07:18 PM   #11
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
Quote:
Originally Posted by pixellany View Post
Not true, you can edit xorg.conf at anytime, and then simply restart X (required for the changes to be effective). ctrl-alt-backspace often does this, or you can open a terminal, su to root, and enter "init 1". To restart X, "init 5"
The key combo, strictly speaking, doesn't restart anything. It just kills X. However, in most systems, the DM is configured to restart X when it dies, but that's the DM, not that key combo.

If you don't use [KGX]DM and you use that key combo you will be back to the command line, and you have to restart X yourself.

Note also that this combo is disabled on newer Xorg versions. You have to explicitly enable it in the xorg.conf file.

But yes, you can edit xorg.conf from within X without a problem. I guess that's what matters here.

Last edited by i92guboj; 10-28-2009 at 07:20 PM.
 
Old 10-29-2009, 07:49 AM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Sorry I was imprecise.....

But then, it WAS correct to say that "ctrl-alt-backspace often restarts X". This is in fact what the user sees on many systems.

i92guboj is of course correct on the details.....
 
Old 10-29-2009, 07:50 AM   #13
systemshock869
LQ Newbie
 
Registered: Oct 2009
Posts: 4

Original Poster
Rep: Reputation: 0
I like nano alot, but unfortunately I'm using Zenwalk (slack), which only has vi and geany as far as I can tell. I liked Xubuntu, and I might go back to it some time, but I really am enjoying Xfce on Zenwalk. It's a lot smoother than Xubuntu. I miss the Ubuntu calendar app though.

Oh yeah, I guess I knew that X didn't have to be killed to edit xorg.conf, because what I do to edit it is log in as root. I haven't found out a way to 'sudo' in slackware yet. When I click on 'root terminal' in accessories, it prompts for my admin password, and then does nothing.
 
Old 10-29-2009, 07:56 AM   #14
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,093

Rep: Reputation: 197Reputation: 197
Quote:
Originally Posted by pixellany View Post
Sorry I was imprecise.....

But then, it WAS correct to say that "ctrl-alt-backspace often restarts X". This is in fact what the user sees on many systems.

i92guboj is of course correct on the details.....
At the risk of confusing the issue further, one some systems ctrl-alt-backspace does nothing but produce a beep but pressing the combination twice in very quick succession will kill X.


Pressing ctrl-alt-backspace is not something you want to be doing as a matter of course. It's useful if you find yourself unable to get out of an X session by logging out but if you can exit the X session by logging out in the usual manner, do so. It's just nicer.
 
Old 10-29-2009, 09:31 AM   #15
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I agree (logging out normally)

When my system locks up, I try ctrl-alt-EVERYTHING before simply pressing the reset button.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Command line text file viewing and editing - .odt etc. mitchellray Linux - Newbie 1 04-14-2009 03:41 PM
editing a line of text using sed suran Programming 6 01-25-2009 03:09 AM
Editing at the command line subnet_rx Linux - General 2 01-09-2007 01:12 PM
editing XF86Config from command line flum Linux - Newbie 4 09-10-2003 04:12 PM
command line editing eddcrossman Linux - Newbie 7 02-16-2003 07:37 PM


All times are GMT -5. The time now is 10:53 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration