change "startx" command | edit: and "ls" [SOLVED]

Forum rules
Before you post please read this

change "startx" command | edit: and "ls" [SOLVED]

Postby lvleow on Wed Aug 24, 2011 3:15 pm

I know this is a little ODD of a request, but how do you go about changing the startx command? For example, instead of startx, I want to type startxx to get into the GUI.
Last edited by lvleow on Mon Aug 29, 2011 5:58 pm, edited 4 times in total.
lvleow
Level 1
Level 1
 
Posts: 42
Joined: Sat Nov 06, 2010 5:32 pm

Linux Mint is funded by ads and donations.
 

Re: change startx command

Postby xenopeek on Wed Aug 24, 2011 3:30 pm

Easy:
Code: Select all
alias startxx="/usr/bin/startx"

Just type that on the terminal to have it work immediately. If you want it to work after reboot, add that line to your ~/.bashrc file.

If you don't want startx to work anymore, that is something different...
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14817
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: change startx command

Postby lvleow on Thu Aug 25, 2011 1:38 am

not quite what I was looking for, but it pointed me in the right dir. thank you. :) renaming startx in /usr/bin to startxx worked more permanently (alias only works for current session?).
lvleow
Level 1
Level 1
 
Posts: 42
Joined: Sat Nov 06, 2010 5:32 pm

Re: change startx command

Postby xenopeek on Thu Aug 25, 2011 1:54 am

lvleow wrote:not quite what I was looking for, but it pointed me in the right dir. thank you. :) renaming startx in /usr/bin to startxx worked more permanently (alias only works for current session?).

Well, I didn't want to suggest that as it may break things (i.e., anything that needs to run startx now can't). Like I wrote, edit your ~/.bashrc to make the alias work after reboot.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14817
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: change "startx" command | edit: and "ls"

Postby lvleow on Fri Aug 26, 2011 8:49 pm

If I edit the bashrc and still put in startx, it'll work right? I don't want that. I want to script a custom error when the input is startx. Besides, what applications might use startx? If you're in the GUI, there's no need for it. And if you're in command, what kind of program wants to interrupt what it's doing and start the GUI? I'm kind of curious, cause I'd prefer not to get that error while doing something in either, so I can just avoid those kinds of apps?

Also, is there a way to rename "ls" to lets say "lss"? Also having ls playback a custom script error? Are there any applications that might use this command as well?

I know, I'm weird. hahaha :lol:
lvleow
Level 1
Level 1
 
Posts: 42
Joined: Sat Nov 06, 2010 5:32 pm

Re: change "startx" command | edit: and "ls"

Postby xenopeek on Sat Aug 27, 2011 2:33 am

lvleow wrote:If I edit the bashrc and still put in startx, it'll work right? I don't want that. I want to script a custom error when the input is startx. Besides, what applications might use startx? If you're in the GUI, there's no need for it. And if you're in command, what kind of program wants to interrupt what it's doing and start the GUI? I'm kind of curious, cause I'd prefer not to get that error while doing something in either, so I can just avoid those kinds of apps?

Also, is there a way to rename "ls" to lets say "lss"? Also having ls playback a custom script error? Are there any applications that might use this command as well?

I know, I'm weird. hahaha :lol:

I suggest you read up on the Bash alias command.

Basically you could do in your ~/.bashrc:
Code: Select all
alias startxx="/usr/bin/startx"
alias startx="echo do not use startx"
alias lss="/bin/ls"
alias ls="echo do not use ls"

As long as you alias your alternative command to the full path of the command's binary, you can then create and alias for the original command to something else (like a warning in this case). If people then type "startx" or "ls" they get a warning, but "startxx" and "lss" work as expected.

If you want this to apply system-wide, for all users on the machine, you have to add the lines to the /etc/bash.bashrc file. The ~/.bashrc is only for your user.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14817
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: change "startx" command | edit: and "ls"

Postby lvleow on Mon Aug 29, 2011 5:39 pm

thank you, I appreciate your help. :)
lvleow
Level 1
Level 1
 
Posts: 42
Joined: Sat Nov 06, 2010 5:32 pm

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests