Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-29-2010, 04:04 PM   #1
LQ Newbie
Registered: Jul 2010
Location: South Africa
Posts: 1

Rep: Reputation: 0
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?

Last edited by martinventer; 07-29-2010 at 04:20 PM.
Old 07-29-2010, 04:07 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
Old 07-29-2010, 04:14 PM   #3
Registered: Jul 2010
Posts: 454

Rep: Reputation: 47
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.
Old 07-29-2010, 04:27 PM   #4
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
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.

$ mount /dev/hda /media/hd
$ !m
In this case !m will do the same mount once more.

$ 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
Old 07-29-2010, 08:20 PM   #5
Senior Member
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,739

Rep: Reputation: 763Reputation: 763Reputation: 763Reputation: 763Reputation: 763Reputation: 763Reputation: 763
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:
/name.of.nas/with/long/dir/name  /mnt/point/of/nas         user,noauto             0       0
can be mounted with
mount /mnt/point/of/nas
which is easy as you even can rely on tab completion.



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
[SOLVED] How to execute files like other commands? ssvirdi Linux - Newbie 3 06-23-2010 02:31 PM
why won't my crontab execute the commands? dannemil Linux - Newbie 4 02-12-2008 06:25 PM
Shell won't execute commands.... frank320 Red Hat 6 03-17-2006 12:12 PM
Finding out how long a program takes to execute nodger Linux - Software 2 11-03-2004 06:31 PM
C -how do i execute linux commands? ocularbob Programming 7 02-29-2004 02:51 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration