Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Location: I live in a world full of anger and hate
Shell Scripting again
Script for chmod (Use exec)
Typing “cmod +x file” every time you want to add execute permission to a shell script is a bit of a pain. Write a shell script called cx, which will run chmod for you. Make sure your cx script will change the modes of all files if used as: cx fiel1 file2 file3 file4
But the even easier way is to create an alias. I don't know if chmod can take multiple files, never tried it, but I guess it can. No way of verifying now as I am nowhere near a linux box.
You could create an alias like this:
alias cx='chmod +x'
Now everytime you run cx actually the chmod 'x gets run. But be carefull, check that cx doesn't already exist as you might do some weird stuff. If cx would be a name of a system file used frequently, then making an alias with the same name would cause problems, because instead of the cx from the system, chmod +x would be called. And you don't want some program randomly changing file permissions to x, now do you?
One minor note about the post above. Instead of using $1, use $@
Using $@ means that _all_ files you pass to the script are used, as compared to just the first one.
And I would suggest an alias, basically:
instead of making a $Script...........one can add this to a right click context menu...........this is from a book
LINUX DESKTOP HACKS
100 Industrial-Strength Tips & Tools by...
Nicholas Petreley & Jono Bacon
All you have to do to create the context menu that will make a file executable
is create a text file formatted very much like an application link, and
then drop it in a special directory. We’ll start by creating a file called make_
executable.desktop. Start up your favorite editor, and enter the following
[Desktop Action MakeExe]
Name=Make file executable
Exec=chmod +x %f
Save your work. The action this file takes is defined by the entry Exec=chmod
+x %f. KDE substitutes the name of the selected file for %f. If you want to
make this feature available to everyone who uses KDE on this computer,
place the file here:
# cp make_executable.desktop <path to kde>/share/apps/konqueror/servicemenus
Create Your Own KDE Right-Click Menu Actions
Depending on your Linux distribution, the path might not be tied to your
KDE directory. It might be /usr/share/apps/konqueror/servicemenus.
If you simply want to make this feature available to yourself, place the file
here (assuming your KDE settings are kept in ~/.kde; your distribution might
use ~/.kde3.3 or something similar):
$ cp make_executable.desktop ~/.kde/share/apps/konqueror/servicemenus
The ServiceTypes field in the file is set to the mime-type
application/x-shellscript, which means the menu option will
be available only when you right-click a shell script file.
Symbols Available for Menu Actions
Konqueror passes the names of selected URLs, selected files, and other
selected elements to your custom menu actions through the use of symbols.
Symbols exist for single files, multiple files, single URLs, and more. The
right-click action that allows you to change a file to be executable works,
because it substitutes the name of the selected file for the symbol %f. Here
are some other symbols available to you, and how they work.
A single filename, even if you select multiple files. In general, you use
this only when you intend to select a single file. In some cases, you can
use this to select several files for use by a program that knows how to
launch a separate instance for each filename.
Multiple selected files. Use this for programs that can act upon several
files at once.
A single URL.
The single directory that contains the selected file represented by %f.
A list of the same directory containing an entry for every selected file in
that directory (%F).
A filename without a path.
Multiple filenames without paths.
A file represented as a URI.