LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Easier way to execute long commands? (https://www.linuxquestions.org/questions/linux-newbie-8/easier-way-to-execute-long-commands-822925/)

martinventer 07-29-2010 03:04 PM

Easier way to execute long commands?
 
I use a long mount command to mount a NAS drive but have to retype it every time I need to mount the drive. Because it is on my laptop I only need to mount the drive from time.

Is there an easier way to do this?

acid_kewpie 07-29-2010 03:07 PM

put the equivalent mount config in your fstab command, or just put the command in a file and run it as a shell script. If yo ukeep your bash history, you can also just hit Ctrl-R and the type in something that is unique in the command like, and it'll provide that command out of your history for you.

CincinnatiKid 07-29-2010 03:14 PM

If it was a fairly recent command, you can press up a couple of times until you get to the command that you want. If you want to mount every time you boot up, I am with acid_kewpie, add it to your /etc/fstab file, if you are not sure of how to do this, let us know.

Dinithion 07-29-2010 03:27 PM

Well, you could add it to fstab, as mentioned. You can make a script that does the mounting. You can also make an alias for that command.

You could also type history to get your history of you commands, then you can use !<num> or !<command> to execute the <num>'th command in the historyfile, or the last command matching <command>, i.e.

Code:

$ mount /dev/hda /media/hd
$ !m

In this case !m will do the same mount once more.

Code:

$ mount /dev/hda /media/hd
$ mtab
$ !m

in this case will run mtab once more. It has to be unique, so in this case you should use !mo or !mount to run the mount command again.

There is a lot of possibilities :)

jlinkels 07-29-2010 07:20 PM

Like said before, put it in fstab, but do add the user,noauto option. Then it won't be mounted automatically, it can be mounted by you as user, and you can mount it using either the device name, or the directory name of the mount point. Like:
Code:

/name.of.nas/with/long/dir/name  /mnt/point/of/nas        user,noauto            0      0
can be mounted with
Code:

mount /mnt/point/of/nas
which is easy as you even can rely on tab completion.

jlinkels


All times are GMT -5. The time now is 06:37 PM.