Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

10 latest updates and drivers and I need to run a game called unreal tournament, but in terminal it requires 2 commands The first one is to mount into the folder:

cd /usr/local/games/ut2004/

and then the second one is to open the actual game:

sudo aoss ./ut2004

In one shortcut i can only fit 1 command but both don't fit in is there any way i can turn these 2 commands into one? Perhaps turni9ng on the desktop shortcut already mounted into the folder? Any help would be really appreciated because im getting kinda sick of using the terminal to run it every time.

share|improve this question
    
Do you need to run the game with sudo? Running a game as root is bad security practice. –  hexafraction Jun 15 '12 at 20:04

6 Answers 6

up vote 10 down vote accepted

cd /usr/local/games/ut2004/ && sudo aoss ./ut2004

share|improve this answer
4  
Using && instead of my proposed ; is a good practise. –  jippie Apr 19 '12 at 20:35
    
@jippie - mind saying why? –  Dominic Rodger Apr 20 '12 at 8:36
    
Because ; would not check if the first command returned a success. CommandA && commandB || commandC basically means 'do command A and, if successful, do command B, otherwise do command C' –  LoremIpsum Apr 20 '12 at 11:07
    
I agree with LoremIpsum. If the cd /usr/local/games/ut2004 fails, it produces an error and the next command (sudo aos ./ut2004) is not executed. To troubleshoot in case of an issue only one error is produced and therefore it is easier to solve. –  jippie Apr 20 '12 at 17:13

Either you enter: cd /usr/local/games/ut2004/; sudo aoss ./ut2004, thus with the extra ; in between ...

... or you create a small shell script in your home directory:

#!/bin/bash

cd /usr/local/games/ut2004/
sudo aoss ./ut2004

and call that from your shortcut.

share|improve this answer

If you want a 'shortcut' you can create a bash function. Add this to your ~/.bashrc file:

function play {
cd /usr/local/games/ut2004/ && sudo aoss ./ut2004
}

Once you save ~/.bashrc run: source ~/.bashrc

(You only have to do that once.)

Now just type this in a terminal:

$ > play

...and hit enter

share|improve this answer
    
play is a bad choice for a command name as it is commonly used to play music files. /usr/bin/play is part of the sox package. –  jippie Apr 20 '12 at 17:15
    
@jippie good call –  jdorfman Apr 21 '12 at 0:54

I think that you could also use

sudo aoss /usr/local/games/ut2004/ut2004

You can create a launcher with that command but using gksu

gksu aoss /usr/local/games/ut2004/ut2004

so you don't have to type it every time!

share|improve this answer
/bin/sh -c "cd /usr/local/games/ut2004/ && sudo aoss ./ut2004"

Note that cd, && and ; are shell built-in operators and will not work in a .desktop shortcut as the command line is directly executed as-is, so you must call a shell to interpret them.

share|improve this answer

You could also create an alias in your .bach_aliases file like 'alias unreal='cd /usr/local/games/ut2004/ && sudo aoss ./ut2004'. That way the next time you login you just type unreal and start playing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.