1./ This tutorial will show you how to set the date and time for Linux
To set your Linux Servers system date and time from the command prompt (bash shell) use the date command to display the current date and time or set the system date / time over ssh session
You must login as root user to use date command.
Linux Set Date
Use the following syntax to set new data and time:
date set=”STRING”
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
date -s "8 FEB 2009 11:00:00"
OR
date set="8 FEB 2009 11:00:00"
2./ This tutorial will show you how to add additional repositories to YUM – Linux Tricks
Yum is a very useful tool when it comes to downloading and installing applications on your Linux server. It is a great tool for keeping your server up to date with the latest releases of applications and operating system patches. Yum makes the work of a server administrator very easy, Easy enough so that even novice users can easily manage their server.
For users that would like to install yum, head over to our tutorial called Installing YUM onto a VPS Linux Server.
This tutorial will guide you through the steps on adding additional repositories to yum.
Yum is a very usefull tool when it comes to downloading and installing applications on your Linux server. It is a great tool for keeping your server up to date with the latest releases of applications and operating system patches. Yum makes the work of a server administrator very easy, Easy enough so that even novice users can easily manage their server. For users that would like to install yum, Head over to our tutorial called Installing YUM onto a VPS Linux Server.
This tutorial will guide you through the steps on adding additional repositories to yum.
Lets assume you have a repository called coolapplications.fastdot.com.au, Create a file called coolfastdot:
# cd /etc/yum.repos.d
# vi coolfastdot
Then add the following lines to the file:
[coolfastdot] name=CoolFastdot for RHEL/ CentOS $releasever – $basearchbaseurl=http://coolapplications.fastdot.com.au/centos/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://coolapplications.fastdot.com.au/RPM-GPG-KEY.txt
Save and close this file.
Keep in mind, You will need to edit the following:
[coolfastdot] – Repository name
name=CoolFastdot for RHEL/ CentOS $releasever – $basearch – Human readable repository name
baseurl=http://coolapplications.fastdot.com.au/centos/$releasever/$basearch/ – Must be a URL to the directory of the repository
enabled=1 – When set to 1, enables the repository. To disable the repository temporarily, set this value to 0.
gpgcheck=1– Security feature to enable GPG Key checking.
gpgkey=http://coolapplications.fastdot.com.au/RPM-GPG-KEY.txt – GPL file location.
You will need to import the GPG Key as follows:
# rpm –import http://coolapplications.fastdot.com.au/RPM-GPG-KEY.txt
Now you are ready to install applications from your newly installed repository!
3./ This tutorial will show you how to how to restart a Linux server from the command
Below is a listing of each of the commands that will enable a user to shut down, turn off, reboot, etc. their Linux computer from the command line.
- halt
- poweroff
- reboot
- shutdown
4./ Linux Shell Commands
The following is a list of Linux shell commands that you might find helpful when modifying your web sites on the server.
Most UNIX commands have many options and parameters which are not listed here. For more complete information on using UNIX commands, you can refer to the online manual by typing man [command] at the UNIX prompt, where “[command]” represents the command you would like more information about.
Other UNIX help commands you can type are [command] -? and [command] –help. Example: man ls
This would bring up the help documentation for the “LS” command.
Note: When something is specified in brackets, such as [command] or [filename], it is used to indicate that you must input your desired information here. Do NOT include brackets in your command.
Navigating in UNIX – Linux Tricks
pwd | Shows the full path of the current directory |
ls | Lists all the files in the current directory |
ls -al | Lists all files and information |
ls –alR | Lists all files and information in all subdirectories |
ls -alR | more | Same as ls –alR, pausing when screen becomes full |
ls -alR > filename.txt | Same as ls –alR, outputs the results to a file |
ls *.html | Lists all files ending with .html |
cd [directory name] | Changes to a new directory |
cd .. | Changes to directory above current one |
clear | Clears the screen |
vdir | Gives a more detailed listing than the “ls” command |
exit | Log off your shell |
Moving, Copying and Deleting Files
mv [old filename] [new filename] | Move/rename a file |
cp [filename] [new filename] | Copies a file |
rm [filename] | Deletes a file |
rm * | Deletes all files in current directory |
rm *.html | Deletes all files ending in .html |
Creating, Moving, Copying and Deleting Directories
mkdir [directory name] | Creates a new directory |
ls -d */ | Lists all directories within current directory |
cp -r [directory] [new directory] | Copies a directory and all files/directories in it |
Searching Files and Directories
find . -name [filename] -print | Searches for a file starting with current directory |
grep [text] [filename] | Searches for text within a file |
File and Directory Permissions
There are three levels of file permissions: read, write and execute. In addition, there are three groups to which you can assign permissions: file owner, user group and everyone. The command chmod followed by three numbers is used to change permissions. The first number is the permission for the owner, the second for the group and the third for everyone. Here are how the levels of permission translate:
0 = — | No permission |
1 = –X | Execute only |
2 = -W- | Write only |
3 = -WX | Write and execute |
4 = R– | Read only |
5 = R-X | Read and execute |
6 = RW- | Read and write |
7 = RWX | Read, write and execute |
It is preferred that the group always have permission of 0. This prevents other users on the server from browsing files via Telnet and FTP. Here are the most common file permissions used:
chmod 604 [filename] | Minimum permissions for HTML file |
chmod 705 [directory name] | Minimum permissions for directories |
chmod 755 [filename] | Minimum permissions for scripts & programs |
chmod 606 [filename] | Permissions for data files used by scripts |
chmod 703 [directory name] | Write-only permissions for public FTP uploading |
Some more Linux Tricks
Sure, here are a few Linux tricks:
1. Use the history command to view your previous commands in the terminal.
2. Use the up and down arrow keys to scroll through your command history.
3. Use the Ctrl+R shortcut to search your command history for a specific command.
4. Use the Tab key to autocomplete file and directory names in the terminal.
5. Use the Ctrl+C shortcut to terminate a running command.
6. Use the Ctrl+Z shortcut to pause a running command and put it in the background.
7. Use the fg command to bring a paused command back to the foreground.
8. Use the kill command to terminate a specific process by its process ID.
9. Use the ps command to view a list of running processes.
10. Use the top command to monitor system resources, such as CPU and memory usage.
11. Use the df command to view disk usage information.
12. Use the du command to view disk usage information for a specific directory.
13. Use the scp command to securely copy files between remote servers.
14. Use the tar command to create and extract compressed archive files.
15. Use the find command to search for files and directories based on various criteria, such as name, size, and modification date.
These are just a few examples of Linux tricks. There are many more commands and shortcuts you can use to make your work easier and more efficient in Linux.