Basic Linux Commands: Click To Edit Master Subtitle Style
Basic Linux Commands: Click To Edit Master Subtitle Style
3/20/12
touch <filename> Creates an empty file Vi <filename> Opens up the vi text editor to create a file. Cat > <filename> overwrites to the file , use ctrl+d to save Click to edit Master subtitle style Cat >> <filename> Appends to the file
3/20/12
Direcotry Commands
v
3/20/12
Changing Direcotry
v
cd <directoryname> Changes the direcotry. pwd Tell the present working directory.
3/20/12
3/20/12
cp <source> <destination> Copies the file / directory. Cp R Copies recursively. mv <source> <destination> Rename or move a file or directory. Click to edit Master subtitle style
3/20/12
rm <filename> Removes a file. Rmdir <directory> Removes an empty directory. Rm rf <directory> Removes the complete directory recursively forcefully,. Click to edit Master subtitle style
3/20/12
User Management
v
Useradd <username> Adds a new user Userdel <username> Removes a user Userdel r <username> Removes the user with data. Click to edit Master subtitle style Passwd <username> Change the password of a user.
3/20/12
Find <path> <pattern> searches for a file in a given path. e.g. find . name test
Which <command> Returns the location of binary , executable for that command. Whereis <command> Returns the location of the binary, configuration and executable for Click to the command.edit Master subtitle style Whatis <command> Provides information about the command.
3/20/12
Zip / Unzip
v
tar -cvf mydata.tar /home/mydata Creates an archive of a folder tar -czf mydata.tar.gz /home/mydata Creates a gzip archive . tar -xzvf mydata.tar.gz Uncompress the gzip file in present working directory. Click to edit Master subtitle style
3/20/12
Rpm e <rpmpackage> Removes the rpm package. Rpm -qa Lists all installed rpms. Click to edit Master subtitle style
3/20/12
mkdir /home/test/vsite/ Create the required directory. Cd /home/test/vsite/ Change present working direcotry. tar zxvf <test.tar.gz> Unzip the compressed file. Note : For files ending in .tar.bz2 Click to edit Master subtitle style tar jxvf <test.tar.bz2> ./configure Pre-installation configuration and creates a Makefile Make Compile the software and build the application binaries. Make install Install the binaries 3/20/12
Yum install <programname> Install the program along with all dependecies from the set repository. Yum reomve <program> Removes the program . Ssh <IP/hostname> Remote login to another computer. Click to edit Master subtitle style Yum list all Lis all the packages in the repository. Location of the repository /etc/yum.repos.d
3/20/12
mount Show the list of mounted location. Mount a Remounts all the mount points mentioned in /etc/fstab Mount /dev/sd1 /mnt Mount a hdd device to a folder. MountClick to edit Master subtitle style /dev/cdrom /mnt Mount a cdrom to mnt folder Mount t cifs //192.168.0.8/softwares o username=xxx, password=xxx /mnt Mount a remote windows share to mnt folder. Umount /mnt umount a location. 3/20/12
Network Management
v
Ifup eth0 To enable the first ethernet device. Ifdown eth0 To disable first ethernet device. Service network restart To restart the network service. Click to edit Master subtitle style Ifconfig To show the network details . Neat Brings up a GUI interface to mange networks.
3/20/12
Run Levels
v
Init <runlevel> Switch to a specific run level. Run Level Meaning 0 Halt 1 Single User 2 Multiuser without NFS 3 Full Multiuser , No GUI 4 Customized 5 GUI Mode Click to edit Master subtitle style 6 Reboot Note : set default run level in /etc/inittab
3/20/12
Service Command
v
Service vsftpd status Check the status of a service Service vsftpd start|stop|restart Start , stop or restart the service. Chkconfig vsftpd on | off To autostart or autostop a service . Click to edit Master subtitle style Chkconfig --list List the service status in different run levels.
3/20/12
Access Permissions.
v
Ls l Shows the access permission on a file / directory. Examples: -rwxr-xr-x File owner has read, write, execute permissions. group: only read and execute permissions. others: only read and execute permissions Click to edit Master subtitle style dr-x-----Directory. owner has read and execute access. group and others have no access
3/20/12
3/20/12
Other Commands
v
Wget http://www.test.example.com/index.html Retrieves web pages via http, https or ftp. Uname r Know the kernel . Ps List the running process status. Click Kill <pid> to edit Master subtitle style Kill the process. Df h Show the free disk space. Du hs <foldername> Check the used space by the folder. Su username 3/20/12 To switch to another user.