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

Friday, January 20, 2017

Console screen resolution for Linux on VirtualBox

Quick Steps

  • Check the resolutions your graphic card supports via the VirtualBox Environment (VBE).You should be able to find that out by issuing the command 'vbeinfo' in the GRUB console (hit the C key when the GRUB boot menu shows up).
  • Change the following parameters: 
  • GRUB_CMDLINE_LINUX="video=AxB-C"
    GRUB_GFXMODE=AxBxC
    GRUB_GFXPAYLOAD_LINUX=keep
    
    Example:
    GRUB_CMDLINE_LINUX="video=1152x864-32"
    GRUB_GFXMODE=1152x864x32
    GRUB_GFXPAYLOAD_LINUX=keep
    
  • Now run these two commands one-by-one:
    sudo update-grub2
    sudo reboot
    
You should now see your VM's console in the custom resolution that you just set.

Wednesday, August 13, 2014

Compile EDB (Evan's Debugger) 32 bit version on Ubuntu 64 bit

These are main steps for compiling EDB (Evan's Debugger) 32 bit version on Ubuntu 64 bit

1. Download tarball
Download tarball here http://freecode.com/projects/edebugger
cd ~/Downloads
tar -zxf debugger-0.9.20.tgz
mv debugger debugger-0.9.20
cd debugger-0.9.20/

2. Install necessary libraries:
a. install GNU libc6 i386
sudo apt-get install libc6:i386 libc6-dev:i386

b. install qt i386 libraries
sudo apt-get install \
libqt4-core:i386 \
libqt4-dbus:i386 \
libqt4-declarative:i386 \
libqt4-designer:i386 \
libqt4-dev:i386 \
libqt4-dev-bin:i386 \
libqt4-help:i386 \
libqt4-network:i386 \
libqt4-opengl:i386 \
libqt4-opengl-dev:i386 \
libqt4-qt3support:i386 \
libqt4-script:i386 \
libqt4-scripttools:i386 \
libqt4-sql:i386 \
libqt4-sql-mysql:i386 \
libqt4-sql-sqlite:i386 \
libqt4-svg:i386 \
libqt4-test:i386 \
libqt4-xml:i386 \
libqt4-xmlpatterns:i386
libqtcore4:i386 \
libqtdbus4:i386 \
libqtgui4:i386 \
libqtwebkit-dev:i386 \
libqtwebkit4:i386 \
qt4-default:i386 \
qt4-designer:i386 \
qt4-dev-tools:i386 \
qt4-qmake:i386 \
qtchooser:i386 \

3. Create symlink to 32 bit headers
cd /usr/include
sudo mv sys sys_x86-64
sudo ln -s i386-linux-gnu/sys .

4. Modify qmake files
a. modify file src/src.pro as follows:

--- a/src/src.proq
+++ b/src/src.pro
@@ -196,20 +196,23 @@ unix {
                INCLUDEPATH += $$LEVEL/include/os/unix/osx /opt/local/include
        }
-       macx {
-               VPATH       += arch/x86_64 $$LEVEL/include/arch/x86_64
-               INCLUDEPATH += arch/x86_64 $$LEVEL/include/arch/x86_64
-       }
-
-       !macx:contains(QMAKE_HOST.arch, x86_64) {
-               VPATH       += arch/x86_64 $$LEVEL/include/arch/x86_64
-               INCLUDEPATH += arch/x86_64 $$LEVEL/include/arch/x86_64
-       }
-       
-       !macx:contains(QMAKE_HOST.arch, i[3456]86) {
-               VPATH       += arch/x86 $$LEVEL/include/arch/x86
-               INCLUDEPATH += arch/x86 $$LEVEL/include/arch/x86
-       }
+    VPATH       += arch/x86 $$LEVEL/include/arch/x86
+    INCLUDEPATH += arch/x86 $$LEVEL/include/arch/x86
+
+       #macx {
+       #       VPATH       += arch/x86_64 $$LEVEL/include/arch/x86_64
+       #       INCLUDEPATH += arch/x86_64 $$LEVEL/include/arch/x86_64
+       #}
+
+       #!macx:contains(QMAKE_HOST.arch, x86_64) {
+       #       VPATH       += arch/x86_64 $$LEVEL/include/arch/x86_64
+       #       INCLUDEPATH += arch/x86_64 $$LEVEL/include/arch/x86_64
+       #}
+       #
+       #!macx:contains(QMAKE_HOST.arch, i[3456]86) {
+       #       VPATH       += arch/x86 $$LEVEL/include/arch/x86
+       #       INCLUDEPATH += arch/x86 $$LEVEL/include/arch/x86
+       #}
        *-g++* | *-clang* {
                QMAKE_CXXFLAGS_DEBUG += -g3

b. modify file plugins/plugins.pri as follows:

--- a/plugins/plugins.pri
+++ b/plugins/plugins.pri
@@ -28,21 +28,24 @@ unix {
        freebsd-* : INCLUDEPATH += $$LEVEL/include/os/unix/freebsd
        macx-*    : INCLUDEPATH += $$LEVEL/include/os/unix/osx /opt/local/include
-       # arch include paths
-       macx {
-               INCLUDEPATH += $$LEVEL/include/arch/x86_64
-               include(plugins-x86_64.pri)
-       }
+    INCLUDEPATH += $$LEVEL/include/arch/x86
+    include(plugins-x86.pri)
-       !macx:contains(QMAKE_HOST.arch, x86_64) {
-               INCLUDEPATH += $$LEVEL/include/arch/x86_64
-               include(plugins-x86_64.pri)
-       }
-       
-       !macx:contains(QMAKE_HOST.arch, i[3456]86) {
-               INCLUDEPATH += $$LEVEL/include/arch/x86
-               include(plugins-x86.pri)
-       }
+       # arch include paths
+       #macx {
+       #       INCLUDEPATH += $$LEVEL/include/arch/x86_64
+       #       include(plugins-x86_64.pri)
+       #}
+
+       #!macx:contains(QMAKE_HOST.arch, x86_64) {
+       #       INCLUDEPATH += $$LEVEL/include/arch/x86_64
+       #       include(plugins-x86_64.pri)
+       #}
+       #
+       #!macx:contains(QMAKE_HOST.arch, i[3456]86) {
+       #       INCLUDEPATH += $$LEVEL/include/arch/x86
+       #       include(plugins-x86.pri)
+       #}
 }
 win32 {

5. Compile and install
cd ~/Downloads/debugger-0.9.20
qmake -spec linux-g++-32
make
sudo make INSTALL_ROOT=/opt/debugger-0.9.20_x86 install
sudo cp -r doc /opt/debugger-0.9.20_x86

6. Create .desktop file
sudo vim /usr/share/applications/edb_x86.desktop
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=edb_x86
Type=Application
GenericName=edb debugger x86
Comment=edb debugger x86
Exec=edb_x86
Icon=/opt/debugger-0.9.20_x86/doc/img/edb_disassembly.png
Terminal=false
Categories=Development;Qt;Debugger;

That's all
Good luck :)

Tuesday, March 4, 2014

CentOS 6 - Restore default top Panel

If you are using CentOS 6 and at some time you changed several configurations of top Panel. After that you want to restore default top Panel configurations, you should do as follows:

1. Remove current Panel settings
rm -rfv /home/<username>/.gconf/apps/panel

2. Logout
3. Login again

Good luck!


Tuesday, October 15, 2013

Clone multiple CentOS VirtualBoxes

Step0:
Enable Virtualization Technology in BIOS  

Step1:
Install CentOS5.7 (Final) with GNOME. This is host machine

Step2:
Install VirtualBox on host machine

Step3:
Create a virtual machine with the following settings:
    System --> Motherboard:
        Chipset: ICH9
        Extended Features: Enable IO APIC, Hardware clock in UTC time
    Storage:
        Controller: SCSI
    Network:
        Attached to: Bridged Adapter

Step4:
Install CentOS5.7 (Final) on virtual machine which is created at Step3

Step5:
Copy file *.vdi to another directory (* = file name)
Execute the following command to change uuid of *.vdi file.
VBoxManage internalcommands sethduuid /path/to/*.vdi

Step6:
Create another virtual machine with copied hard disk.

Step7:
Start new virtual machine

Step8:
Repeat Step5~7 if you want to clone more virtual machine.

Monday, October 14, 2013

How to install GNOME desktop from DVD

Source: http://superuser.com/questions/432000/how-to-install-gnome-desktop-from-dvd-on-centos-6-using-the-command-line

As you have installed CentOS in VirtualBox, and as I understand, while installing you haven't choose X window system, so you are getting black screen with white cursor blinking.

Now what you can do is, install X Window System. If you have internet access in VirtualBox then you can try

yum groupinstall "X Window System"
This will use your internet connection to download the packages and install on system.

If you don't have internet access in VirtualBox then I will suggest you to mount the CD ROM in a virtual machine and install using that.

First of all you need to create a mount point and mount the Installation Media

mkdir /medir/cdr
mount /dev/cdrom /media/cdr
Now you have to create a local repository in /etc/yum.repo.d/

cd /etc/yum.repo.d/
vi local.repo
In this file write

[installation Media]
Name="Centos Local Installation"
baseurl=file:///media/cdr
enabled=1
gpgcheck=0
Now you can install the X Window system using

yum groupinstall "X Window System" "GNOME Desktop Environment"

Tuesday, August 6, 2013

BASH Shell Color


Source: http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

 

BASH Shell: Change The Color of My Shell Prompt Under Linux or UNIX

by  on OCTOBER 6, 2006 · 50 COMMENTS· LAST UPDATED MARCH 6, 2013
How do I change the color of my shell prompt under Linux or Unix operating systems?

You can change the color of your shell prompt to impress your friend or to make your own life quite easy while working at the command prompt. BASH shell is the default under Linux and Apple OS X. Your current prompt setting is stored in a shell variable called PS1. There are other variables too, like PS2, PS3 and PS4.
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsBash
Estimated completion timeN/A

Bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters.

Task: Display current BASH prompt (PS1)

Use the echo command to display current BASH prompt:
$ echo $PS1
Sample outputs:
[\\u@\h \\W]\\$
Here is another output from my Debian based system:
$ echo $PS1
Sample outputs:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
By default the command prompt is set to [\u@\h \W]\$. The backslash-escaped special characters are decoded as follows:
  • \u: Display the current username .
  • \h: Display the hostname
  • \W: Print the base of current working directory.
  • \$: Display # (indicates root user) if the effective UID is 0, otherwise display a $.

Task: Modify current BASH prompt

Use the export command to setup a new shell prompt:
$ export PS1="[\\u@\\H \\W \\@]\\$"
Sample outputs:
Fig.01: New prompt in action
Fig.01: New prompt in action

Where,
  • \H: Display FQDN hostname.
  • \@: Display current time in 12-hour am/pm format

Task: Add colors to the prompt

To add colors to the shell prompt use the following export command syntax:
'\e[x;ym $PS1 \e[m'
Where,
  • \e[ : Start color scheme.
  • x;y : Color pair to use (x;y)
  • $PS1 : Your shell prompt variable.
  • \e[m : Stop color scheme.
To set a red color prompt, type the following command:
$ export PS1="\e[0;31m[\u@\h \W]\$ \e[m "
Sample outputs:
Fig.02: Adding the colors to the prompt
Fig.02: Adding the colors to the prompt

A list of color codes

ColorCode
Black0;30
Blue0;34
Green0;32
Cyan0;36
Red0;31
Purple0;35
Brown0;33
Blue0;34
Green0;32
Cyan0;36
Red0;31
Purple0;35
Brown0;33
Note: You need to replace digit 0 with 1 to get light color version.

Task: How do I make the prompt setting permanent?

Your new shell prompt setting set by $PS1 is temporary i.e. when you logout setting will be lost. To have it set every time you login to your workstation add above export command to your $HOME/.bash_profile file or $HOME/.bashrc file.
$ cd
$ vi .bash_profile

OR
$ vi $HOME/.bashrc
Append the following line:
export PS1="\e[0;31m[\u@\h \W]\$ \e[m"
Save and close the file.

Say hello to tput command

You can also use tput command to set terminal and modify the prompt settings. For example, to display RED color prompt using a tput:
export PS1="\[$(tput setaf 1)\]\u@\h:\w $ \[$(tput sgr0)\]"

A list of handy tput command line options

  • tput bold - Bold effect
  • tput rev - Display inverse colors
  • tput sgr0 - Reset everything
  • tput setaf {CODE}- Set foreground color, see color {CODE} table below for more information.
  • tput setab {CODE}- Set background color, see color {CODE} table below for more information.

Various color codes for the tput command

Color {code}Color
0Black
1Red
2Green
3Yellow
4Blue
5Magenta
6Cyan
7White
RECOMMEND READINGS

Friday, July 20, 2012

Linux useful command

Redirect output:
< file means open a file for reading and associate with STDIN.
<< token Means use the current input stream as STDIN for the program until token is seen. We will ignore this one until we get to scripting.
> file means open a file for writing and truncate it and associate it with STDOUT.
>> file means open a file for writing and seek to the end and associate it with STDOUT. This is how you append to a file using a redirect.
n>&m means redirect FD n to the same places as FD m. Eg, 2>&1 means send STDERR to the same place that STDOUT is going to.


/etc/sudoers Syntax

To fully explain the syntax of /etc/sudoers, we will use a sample rule and break down each column:
jorge  ALL=(root) /usr/bin/find, /bin/rm
The first column defines what user or group this sudo rule applies to. In this case, it is the user jorge. If the word in this column is preceded by a % symbol, it designates this value as a group instead of a user, since a system can have users and groups with the same name.
The second value (ALL) defines what hosts this sudo rule applies to. This column is most useful when you deploy a sudoenvironment across multiple systems. For a desktop Ubuntu system, or a system where you don't plan on deploying thesudo roles to multiple systems, you can feel free to leave this value set to ALL, which is a wildcard that matches all hosts.
The third value is set in parentheses and defines what user or users the user in the first column can execute a command as. This value is set to root, which means that jorge will be allowed to execute the commands specified in the last column as the root user. This value can also be set to the ALL wildcard, which would allow jorge to run the commands as any user on the system.
The last value (/usr/bin/find, /bin/rm) is a comma-separated list of commands the user in the first column can run as the user(s) in the third column. In this case, we're allowing jorge to run find and rm as root. This value can also be set to the ALL wildcard, which would allow jorge to run all commands on the system as root.

Make ISO image

We’re going to use the command line tool dd tool for this. Insert the disc that you want to copy and open a terminal.

Create a cdrom image

Now in the terminal type:


1
sudo dd if=/dev/cdrom of=cd.iso

A little explanation
  • sudo makes sure the command is executed as root. That’s needed only if the user you’re working under doesn’t have enough permissions to access the device. But it’s ignored if it’s not needed so you can just ignore it as well.
  • dd stands for Disk Dump
  • if stands for Input File
  • of stands for Output File
Wait for the command to finish, and your new iso will be saved to cd.iso.

Create a dvd image

For a DVD image, your device is probably called /dev/dvd instead of /dev/cdrom so the command would look like this:


1
sudo dd if=/dev/dvd of=dvd.iso

Create a scsi cdrom image

For a SCSI CDROM image, your device is probably called /dev/scd0 instead of /dev/cdrom so the command would look like this:


1
sudo dd if=/dev/scd0 of=cd.iso

Mounting an image

Once you’ve created an ISO image you can mount it as if it was a normal disc device (loopback) device. This will give you access to the files in the ISO without you having to burn it to a disc first. For example if you wanted to mount cd.iso to /mnt/isoimage you would run the following commands:


1
2
3
mkdir -p /mnt/isoimage

mount -o loop -t iso9660 cd.iso /mnt/isoimage

Unmounting

To unmount a currently mounted volume, type:


1
umount -lf /mnt/isoimage

/mnt/isoimage is the location of your mounted volume.

Force Mac OS Lion create new account
mount -uw/
rm /var/db/.AppleSetupDone
shutdown -r now

Mount Directory
vi /etc/fstab

Add below line
/var/www/html/test   /home/test/test          none        bind     0 0  

Sudoers
You can take a command out of a sudo account by using the ! (not operator) for example to let bill use all commands except su, shutdown, halt and poweroff the line would look like (in /etc/sudoers)

Code:
bill        ALL = (ALL) ALL !su !shutdown !halt !poweroff
this does not seem like a good idea as there may be ways around the exact command. such as using a shell escape from another program.

You can give access to directorys just like you can command. for example if you wanted bill,mike,pete and members of the project group to be able to access /path/to/project/*. you'd use 

Code:
User_Alias     THISGROUP = bill, mike, pete

THISGROUP, %project ALL= /path/to/project/*
the user alias statement should be near the top all other statements should be with the main body of statements in sudoers file