Eleven Really usefull Linux Tips
1. Making linux files and folder unalterable : -
Suppose one has a folder/file 'linux' and you want to make it unalterable so that it does not get deleted mistakenly. This can be done with the following command
chattr -R +i [Replace this with the folder address , in this case it is /home/ambuj/linux]
After completeing the step the folder becomes unalterable and even the superuser - ' root' cannot delete the folder.
Now if you again want to delete the folder it can be done first by removing these attributes from the folder
chattr -R -i [ Folder address, /home/ambuj/linux in this case ]
Now the folder can be removed.
2. Resetting user password
There are often case when some new user forgets his/her password , this password can be reset by the root user
using command
passwd [name of user]
this will ask for new user password of the user.
3. Recovering lost root password
if one has lost his root/superuser password , then the password can be easily be reset to a new password using the following steps : -
If you have grub installed as a boot manager at the boot screen type 'e' to enter into edit mode select the kernel you want to load and add 'single' at the end . Exit the edit mode and boot into the kernel by typing the b mode . this will enter the user into a single user mode where from one can change the root password by typing the command : -
passwd
if you have LILO installed as boot manager then
type linux single at boot prompt. to boot into a single super user mode .
after booting into the single superuser mode type
passwd to reset the password.
However if you are running graphical LILO then enter the text boot: prompt by typing Ctrl + X and repeat the above steps.
4. Playing mp3 files at command line
mpg123 is command line based audio player that forms the backbone of number of graphically available Audio players , it is one of the most efficient player on the Linux platform and can play mp3 files on as low hardware specs as a 120Mhz Pentium Processor based computer . A similar command line application is mpg321 that can be used for playing mp3 files.
Ctrl + C - This skips to next track
Typing Ctrl + C Twice - quits the application
mpg123 -z *.mp3 : - Command would play all the mp3 files in the directory with a shuffled play-list. mpg123 -w filename.wav filename.mp3 :- This command would convert the mp3 file to wav file , whic can then be used for burning on to cd to make audio cd.
mpg123 $ (find -name "Filename")
5. Running any application with keystrokes in Metacity(Gnome)
In Gnome it is very easy to run any program you want with a keystroke , you can assign any program to a keystroke and the program would launch when you type those keystrokes. For Example : if you assign
To do this first launch gconf-editor
Now open apps -> metacity -> global keybinding
Now choose the keystroke you want to associate command with for example chose run_command_1 and type the valueAfter doing this go to apps -> metacity -> keybinding_command and chose the command you have set the value , and put the name of command you want to execute as the value of the command . Now exit the gconf-editor , the KeyStroke should have been properly adjusted now when you type the selected KeyStroke your selected command is executed.
6. Creating symbolic links in linux
Symbolic links if you have used windows is way of making short cuts in linux , now using a symbolic link you can refer to any file or directory by another file name in different directory .
ln -s [Path of script , folder file] [path where to create shortcut/name of shortcut]
example : to create symbolic link of folder /windows type ln -s /windows /home/amXXX/win
Creates link of folder /windows at /home/amXXX with name win.
7. Creating Directories and subdirectories quickly
Directories and sub-directories can be created quickly with a single statement saving some of your time. For example if you want to create the following directory structure
Temp -> a ->(b -> c) , d->(e->f->g),h,i,j
you can do this with the following commands
mkdir temp
cd a
mkdir b
mkdir c
........ (and so on)
or you can reduce the number of commands typed by using a statement like this : -
mkdir -p Temp/{a/b/c,d/e/f/g,h,i,j}
This would create all the directories in single line without you having to type a lot of mkdir and chdir.
8. Extracting a archive in a particular directory
If you want to extract a particular archive in a particular directory you don't have to move the archive to that particular directory and chdir to that directory and extract the archive this can be done easily by using command like this : -
Example : to extract file newfile.tar.gz to directory Temp/a/b use following command
tar xvf -C Temp/a/b newfile.tar.gz
9. Viewing listing of files in particular directory page wise
If you have a really long file list in a particular directory you can view the files page wise by piping the output ls to more command.
ls -l | more would view the content of the directory page-wise.
10. Turning off annoying PC Speaker Beep
If you are really annoyed by the beep computer produces using the PC speaker you can turn it off using the following command : -
rmmod pcspkr
To re-enable the PC Speaker beep use the following command
modprobe pcspkr
11. Changing the background of nautilus file manager
Nautilus file manager by default doesn't provide a way of changing the background of file manager , how ever if you want to set the background of nautilus file manager to something different say pic.jpg file this can be easily done by the following command .
gconftool-2 /apps/nautilus/preferences/background_set -t bool -s true
gconftool-2 /apps/nautilus/preferences/background_filename -t string \-s {Image name with path}
Thanks for the tips, I am hoping that I will learn Linux someday and I wanted to have that kind of knowledge regarding operating systems.
ReplyDeleteWhere is the command?
ReplyDelete