Linux Tips

Everything IT: computers, software, internet

Moderators: Vega, Dixie

Linux Tips

Postby Sunnypk » Tue May 18, 2010 3:43 am

Overview of the Linux file system

/bin All commands which are used by normal users

/etc System conf files

/var Server data logs Mail proxy cache

/dev All devices name stored in /dev

/sbin All commands which are used by supper user

/boot Linux kernel ( vmlinuz , initrd ) Grub directory

/usr All gui tools installed in /usr

/proc System information’s ( picture of RAM )

/home User's home dir's

/tmp Temporary files

/media Auto mounted devices mount point in /media


Linus Basic Commands


For changing directory / to /etc

[root@pc1 /]# cd /etc



One step back /etc to /

[root@pc1 etc]# cd ..



Go to previous working directory

[root@pc1 /]# cd -



Go to current login user home directory

[root@pc1 etc]# cd ~



Show the contents of /etc in single color

[root@pc1 ~]# dir /etc



Show the contents of /etc in different colors with nature of contents

[root@pc1 ~]# Ls /etc



create a folder on root partition

[root@pc1 ~]# mkdir /disk



Create a folder in /disk

[root@pc1 ~]# mkdir /disk/dir



Create multiple folder in multiple directories with single command

[root@pc1 ~]# mkdir /etc/dir1 /var/dir2 /usr/dir3



Create multiple folder in same directory

[root@pc1 ~]# mkdir dir1 dir2 dir3



Copy a file in directory

[root@pc1 disk]# cp file dir



Copy a file from /disk/file and paste it in /disk/dir/

[root@pc1 disk]# cp /disk/file /disk/dir



Copy a directory with –r option

[root@pc1 disk]# cp -r dir dir2



Copy a file from /disk/file and paste it in /etc with myfile name

[root@pc1 disk]# cp /disk/file /etc/myfile



Remove a file

[root@pc1 disk]# rm file



Remove a file with forcefully option

[root@pc1 disk]# rm –f file



Remove a directory with out –r option and you face will an error

[root@pc1 disk]# rm dir



Remove a directory with –r option

[root@pc1 disk]# rm -r /disk



Remove a directory with forcefully option

[root@pc1 disk]# rm -rf dir



Move /etc/dir1 to /disk/ with different name

[root@pc1 disk]# mv /etc/dir1 /disk/mydir

Rename the folder name mydir to dir

[root@pc1 disk]# mv /disk/mydir /disk/dir



Rename the file name with myfile

[root@pc1 disk]# mv file myfile



Read a file page by page with less command

[root@pc1 disk]# less /etc/grub.conf



Read a file page by page with more command

[root@pc1 disk]# more /etc/qrub.conf



Read first ten lines of grub.conf

[root@pc1 disk]# head /etc/grub.conf



Read last ten lings of grub.conf

[root@pc1 disk]# tail /etc/grub.conf



Read first 12 lines with –n option

[root@pc1 disk]# head -n 12 /etc/grub.conf



Read last 11 lines with –n option

[root@pc1 disk]# tail -n 11 /etc/grub.conf



Copy the contents of /etc/grub.conf in /disk/file

[root@pc1 disk]# cat /etc/grub.conf > /disk/file



Append the contents /etc/mtab in /etc/file

[root@pc1 disk]# cat /etc/mtab >> /disk/file



Merging tow commands with pipe sign output of the first command is input of second command

[root@pc1 disk]# cat /etc/squid/squid.conf I more

Count the total lines of squid.conf

[root@pc1 disk]# cat /etc/squid/squid.conf I wc -L



Show only spool words in squid.conf

[root@pc1 disk]# cat /etc/squid/squid.conf I grep spool



Flush the contents of file

[root@pc1 disk]# cat /dev/null > /var/log/messages

Free Linus Help Line

[root@pc1 disk]# man mkdir
[root@pc1 disk]# info mkdir
[root@pc1 disk]# whatis mkdir
[root@pc1 disk]# mkdir - - help
[root@pc1 disk]# apropos "partition"


How to configure Linux Files Permissions?

Three types of permission read write and execute, Ever file and folder have three relations owner group and

others

[ Read = r write = w execute = x ] [ owner = u group = g other = o ]

[root@pc1 ~] # Ls -Ld /disk



1= nature of object [d=dir -=file L=link]

2= first three permission for owner [ rwx ]

3= second three permission for group members [ r-x]

4= third three permission for others [r-x]

5= number of inodes contain by this directory

6= owner of directory

7= group of directory

8= size of directory

9= creating date of object

10= name of object



[root@pc1 ~] # Ls -L /disk

Drwxr-xr – x 2 root root 4096 Jan 1 1988 dir1

Drwxr-xr – x 2 root root 4096 Jan 1 1988 dir2

Drwxr-xr – x 2 root root 4096 Jan 1 1988 dir3

Changing permission = give write permission to other on /disk

[root@pc1 ~] # chmod 0+w /disk

Give read write and execute permission for group on /disk

[root@pc1 ~] # chmod g+rwx /disk

Assigning read writ and execute permission to user, group and other with single command

[root@pc1 ~] # chmod u+rwx , g+rwx, o – rwx /disk

Assigning different permission with different commands which separate with semicolon

[root@pc1 ~] # chmod u+rwx /disk ; chmod g+rwx /disk ; chmod 0+rx /disk

Using number system =----- [ Read = 4 ] [ Write = 2 ] [ Execute = 1 ]

rwx=7

r-x=5

---=0

Assigning full permission to owner and no permission for group and others

[root@pc1 ~] # chmod 700 /disk

Assigning full permission for owner and group no permission for other

[root@pc1 ~] # chmod 700 /disk

Assigning full permission to all

[root@pc1 ~] # chmod 777 /disk

Assigning full permission for owner and read, and execute for group and others

[root@pc1 ~] # chmod 755 /disk

Assigning no permission for all

[root@pc1 ~] # chmod 000 /disk

Assigning sticky bit permission for other

[root@pc1 ~] # chmod o+t /disk

Assigning suid permission for owner

[root@pc1 ~] # chmod u+s /disk

Assigning sgid permission for group
[root@pc1 ~] # chmod g+s /disk
User avatar
Sunnypk
Rough Diamond Member
 
Posts: 1648
Joined: Wed Nov 08, 2006 3:55 pm
Location: Pakistan
Status: English Learner

Re: Linux Tips

Postby Hardi » Wed Nov 24, 2010 9:22 am

I like to use "Midnight Commander" ( mc ) to browse the context of directories..

You leaved one important tip out. The tip, that in most Linux-distributions, u could switch between terminals, by pressing [Ctrl] + [Alt] + ([F1] to [F7]) This works also when you're in graphical environment. ...Graphical desktop environment runs usually under [F7] leaving 1 to 6 free for other use...

It's a very useful. When learning to use Linux commands.
U can have the man page opened in one terminal to peek, while u edit configuration file on other terminal, or typing commands on another terminal window.. by switching between them, by pressing those shortcuts.. and u can be logged in as different user in each terminal.. I think this is the most important thing, that should be taught as first thing to new Linux users.. especially to the ones with bad memory, like my self. ;)
Hardi
Polished Diamond Member
 
Posts: 2136
Joined: Fri Aug 20, 2004 7:44 pm
Location: European Union
Status: Other


Return to Information Technology

Who is online

Users browsing this forum: No registered users and 2 guests