make 'srm' the default command instead 'rm' in linux [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I want force users to use 'srm' instead of 'rm' command. is there any solution to execute 'srm' command when users run rm command? or deny users permissions to run 'rm'?

Just create an alias:
alias rm='srm'
You can put this command in the .bashrc file for the user you have to keep under control, so that it is automatically loaded at login.
You can also put it into /etc/bashrc, so that it's loaded for ALL the users.

You can use aliases to do this.
Create an alias as ,
alais rm="srm"
Add this in to the bash_profile or bashrc file or even better create a bash_alias file that will be called from bashrc file.
For a general intro on Aliases, refer this http://bit.do/freblogg-aliases

Related

How to alias or rename a file on the fly in Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have the following challenge under Linux:
An application is writing a config-file "samename.cfg" into certain directories
I want to have the config-file named different for each directory
I do not want any file called "samename.cfg" written to the directories
I can not change it in the application
So I would like to have the application thinking that it accesses samename.cfg but in fact it reads and writes anothername.cfg. Symlink does not help, because then there still is a file called samename.cfg in every directory.
Anybody any idea?
Regards,
Axel
Try using a hard link instead of a soft link when using ln command (just remove the -s flag).
See ln man's page for more details.

Where do we have to put a linux command? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I just coded a script in bash on Ubuntu but I don't know where I should put it...
I read I had to put it in /usr/bin in a tutorial but maybe it's better directly in /bin ?
This is the difference between both directories:
/bin
It contains commands that can be used by both the system administrator and the users, but which are necessary when other file systems are not mounted (for example, in single user mode). It can also contain commands that scripts use indirectly
/usr/bin/
This is the main directory of executable commands in the system.
Therefore, it will work on both, but you must establish what responsibility your script has.

I accidentally copied a bash file replacing it with the .bashrc file in my Linux Mint. How am I supposed to retrieve the .bashrc file? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I was trying to place my bash file to the bin, but i copied the contents to the .bashrc file, replacing the contents of the original file. I would like you to help me get back the .bashrc file.
You cannot recover your custom .bashrc. But, if you want to restore it to the default .bashrc, you will find the one copied when creating a new user in:
/etc/skel/.bashrc

Is there an easy way to deal with files with long filenames and long directory names in linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Suppose I have a directory on my disk that has the name: photos_with_my_friend_John_from_first_semester_of_my_graduation_year
Now each time I want to enter this directory I must write the following command:
cd photos_with_my_friend_John_from_first_semester_of_my_graduation_year
I am new to linux and for me it is very boring to write this whole name each time I want to deal with this directory or any other directory or file that has such a long name. So is there an alternative easy way to do this?
Most shells offer tab completion: You simply type cd phot and hit Tab, and it'll insert the rest for you (assuming the prefix is unique).
How about using wildcards? Say photos*John*graduation etc.?
You can create a symbolic link for ease of access:
ln -s long_file_name short_file_name
then you can use short_file_name as you wish.

is there a way to do Linux ifup or ifdown in bash without always having to type sudo first? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
For ifup/ifdown, service, and other commands, is there a way around always needing to type sudo first?
Linux version is 3.8.13-bone67
the simplest way:
add the following in your ~/.bashrc:
alias ifup='sudo /usr/bin/ifup'
(or whatever is the path to your ifup binary. If you don't know the path, you can find out using which ifup)
You then have to enter your password as regular. To also avoid typing the password, you can add an entry into your sudoers file.
Use $ sudo visudo to edit it (will use the editor defined in $EDITOR or vi) and add a line like the following to the end:
ALL ALL = NOPASSWD: /full/path/and/full/command
Sources:
https://wiki.archlinux.org/index.php/Sudo#Configuration

Resources