Pages

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Aug 12, 2012

Recover Grub2 via LiveCD (Fedora16/17)

After installing the windows 8 RTM in my computer, I can't boot into my Fedora 17. I need to fix the grub2.

I use the Fedora LiveCD to fix it. First, boot the liveCD, and then open a terminal and type:
$ sudo fdist -l
Now, remember which device listed is your Linux distribution. For example, my Linux distribution is in /dev/sda3
$ sudo mount /dev/sda3 /mnt
If you have /boot on a separate partition, you need to mount it too. For instance, your /boot partition is /dev/sda2, you need run sudo mount /dev/sda2 /mnt
$ sudo mount --bind /dev /mnt/dev
$ sudo chroot /mnt
# grub2-install /dev/sda
After this command, it will show you the grubs is installed successfully and then you can reboot. The grub2 list comes back now.

When you boot into your original Fedora, open the terminal and type:
$ su -c 'grub2-mkconfig -o /boot/grub2/grub.cfg'
It will update your boot list.

Jan 31, 2012

How to Configure the Linux before using the fastboot mode of Android

After installing the android sdk, we still need some configuration before using the fastboot mode of the nexus s on Linux.

Firstly, we need the device ID of the android device, here is the nexus s. Connect the nexus s to the computer via USB, then type "lsusb" in the terminal, see figure 1. In the last line, we can see the ID "18d1:XXXX".
Fig. 1
Then, create a file in "/etc/udev/rules.d" named "51-android.rules". Copy "UBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"" into the file. After rebooting, you can use the fastboot mode.

Sep 10, 2011

A Bash Script to Create Multiple User Accounts in a Batch

There are a lot of introductions on the Internet about how to create multiple user accounts in a batch with "newusers" command. But in this way, there are some problems about the environment variables. The system will not initialize the ".bashrc" and the ".bash_proflie" files.

Here is anther way to create multiple user accounts with "useradd" command.
#!/bin/bash
password="123456"
for USER in $(cat example_userlist)
do
    useradd -m $USER
    echo -e "${password}\n${password}" | passwd $USER
done
The password of all the users is "123456", it can be changed in the second line.

In this script, the "example_userlist" is a list of user names, the format of this file is like this:
user1
user2
user3
...
Enjoy!

Jun 11, 2011

How to setup a web server on Fedora 15 with Apache+MySQL+PHP (LAMP)

It had been three years since I first knew Linux. I had tried several different distributions like Ubuntu, Fedora and OpenSUSE, but I didn't have enough time to learn it in depth.

Now I have a plan to learn more about linux (Fedora), such as setting up a web server, starting a FTP server, doing some development, etc.

I had setup a web server successfully recently. The methods are as follows (my system is Fedora 15, there are some differences in other systems):

Firstly, install Apache, MySQL and PHP, run follow commands:
$ su
# yum install mysql-server httpd php
Now, you should have necessary packages installed. After installed, you must set a password for mysql root usr:
$ su
# systemctl start mysqld.service
# mysqladmin -u root password PASSOWRD_HERE
To run the apache and mysql services, enter the following in terminal. This should be done each time you want to use.
$ su
# systemctl restart mysqld.service
# systemctl restart httpd.service
The web server directory is "/var/www/html/". If you want the services to start with your OS, run the follows:

$ su
# systemctl enable mysqld.service
# systemctl enable httpd.service
At last, you must check the firewall to confirm the port 80 is open.



After all the above are done, open your browser and visit http://127.0.0.1, you can see a test page: