The following script,when executed, will create 2014 on the linux terminal.
Search
Christmas bell on linux terminal
Run the following script to generate a bell on the linux terminal.
#!/bin/bash
str_dwn() {
rows=$1
s_start=$2
char=$4
str_st_row=$3
rows_end=$((str_st_row+rows))
for((i=str_st_row;i
Run the script as follows
$ chmod 777 bell.sh
$ ./bell.sh
What character do you want to use
*
Choose the size of the bell, enter a number
10
Audio/Sound output coming from both speaker and headphones at same time
On installation of a new version of linux it might happen that the audio/sound output keeps coming from the speaker of the laptop even after plugging in a headphone into its socket. The expected behaviour is that when we plug in the headphone, sound should only be coming in the headphone and nothing should be audible from the laptop speakers.
After going over number of possible solutions using available on the net what worked was updating the alsa driver by downloading the latest one from http://www.alsa-project.org/main/index.php/Download
The default version of driver installed was 1.0.23, but the update one available on the site was 1.0.25.
To solve the above mentioned problem download the latest driver source, compile it and install it using the following commands.
Assume that we have downloaded the driver for version 1.0.25 which has the package name alsa-driver-1.0.25.tar.bz2
$ tar -xjvf alsa-driver-1.0.25.tar.bz2
$ cd alsa-driver-1.0.25
$ ./configure
$ make
$ sudo make install
Please note that the last step will require root permissions.
Now restart the system and the laptop speaker should get muted automatically on plugging in the headphones.
After going over number of possible solutions using available on the net what worked was updating the alsa driver by downloading the latest one from http://www.alsa-project.org/main/index.php/Download
The default version of driver installed was 1.0.23, but the update one available on the site was 1.0.25.
To solve the above mentioned problem download the latest driver source, compile it and install it using the following commands.
Assume that we have downloaded the driver for version 1.0.25 which has the package name alsa-driver-1.0.25.tar.bz2
Please note that the last step will require root permissions.
Now restart the system and the laptop speaker should get muted automatically on plugging in the headphones.
Creating directory under /proc in kernel 3.10 and above
In the post Creating a read write proc entry in kernel versions above 3.10 we saw the creation of read write proc entry. In the post we will see how to create folder under /proc and then create a entry under it.
To create a directory under /proc we can make use of the function
struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent);
Where
name: is the name of the directory to be created. parent: parent is the name of directory under which the new directory has to be created.
To create a directory named "newparent" under /proc we will first declare a string having the name of the new folder
char *dirname="newparent"
struct proc_dir_entry *parent
newparent=proc_mkdir(dirname,NULL)
The NULL is passed for parent as we are creating the folder under /proc.
Once the new folder has been created we need to pass the pointer to struct proc_dir_entry to proc_create. The use of proc_create can be seen in the post
proc_create("hello",0,newparent,&proc_fops,NULL)
The full code for the module along with proc creation will be as shown below. Please refer to the post Creating a read write proc entry in kernel versions above 3.10 for more details
proc_dir.c
#include
#include
#include
#include
#include
#include
int len,temp;
char *msg;
char *dirname="newparent";
struct proc_dir_entry *parent;
int read_proc(struct file *filp,char *buf,size_t count,loff_t *offp )
{
if(count>temp)
{
count=temp;
}
temp=temp-count;
copy_to_user(buf,msg, count);
if(count==0)
temp=len;
return count;
}
int write_proc(struct file *filp,const char *buf,size_t count,loff_t *offp)
{
copy_from_user(msg,buf,count);
len=count;
temp=len;
return count;
}
struct file_operations proc_fops = {
read: read_proc,
write: write_proc
};
void create_new_proc_entry()
{
parent=proc_mkdir(dirname,NULL);
proc_create("hello",0,parent,&proc_fops);
msg=kmalloc(GFP_KERNEL,10*sizeof(char));
}
int proc_init (void) {
create_new_proc_entry();
return 0;
}
void proc_cleanup(void) {
remove_proc_entry("temp1",NULL);
}
MODULE_LICENSE("GPL");
module_init(proc_init);
module_exit(proc_cleanup);
The makefile for the same
ifneq ($(KERNELRELEASE),)
obj-m := proc_rw_3_10.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
Compile and load the module using
$ make
$ insmod proc_dir.ko
If there are no errors then we can find the new proc entry under /proc
$ ls /proc/newparent
hello
Thus we can see that under /proc a new folder called newparent has been created in which the proc entry hello has been created. We can read write to this proc entry like other proc entries
$ echo "hi" > /proc/newparent/hello
$ cat /proc/newparent/hello
hi
Related posts
Creating a read write proc entry in kernel versions above 3.10
Creating read only proc entry in kernel versions above 3.10.
Creating a proc entry - 1
To create a directory under /proc we can make use of the function
Where
name: is the name of the directory to be created. parent: parent is the name of directory under which the new directory has to be created.
To create a directory named "newparent" under /proc we will first declare a string having the name of the new folder
The NULL is passed for parent as we are creating the folder under /proc.
Once the new folder has been created we need to pass the pointer to struct proc_dir_entry to proc_create. The use of proc_create can be seen in the post
The full code for the module along with proc creation will be as shown below. Please refer to the post Creating a read write proc entry in kernel versions above 3.10 for more details
proc_dir.c
The makefile for the same
Compile and load the module using
If there are no errors then we can find the new proc entry under /proc
Thus we can see that under /proc a new folder called newparent has been created in which the proc entry hello has been created. We can read write to this proc entry like other proc entries
Related posts
Creating a read write proc entry in kernel versions above 3.10
Creating read only proc entry in kernel versions above 3.10.
Creating a proc entry - 1
Quiz Solution
Answers to Quiz based on chapter-4 of book linux device drivers 3rd ed
1. Which of the following config options need to be enabled to be able to debug kernel.
Ans.CONFIG_DEBUG_KERNEL
2.The first argument passed to printk specifies the
Ans.loglevel for the message to be printed
3.The command that can be used to view the kernel logs from user space is
Ans. dmesg
4. The function create_proc_read_entry returns a pointer to
Ans.struct proc_dir_entry
5.The seq file interface is used for
Ans. Passing kernel information to user space
6. Output of strace shows
Ans. The system calls made by a user application
7. In a kernel oops message EIP points to
Ans. The address of the faulty instruction
8. While using gdb for kernel debugging the kernel core file used passed to gdb is
Ans. /proc/kcore
9.Which of the following keys will launch the kdb
Ans. Pause
10. To use kgdb we need two systems connected by a serial cable
Ans. True
1. Which of the following config options need to be enabled to be able to debug kernel.
Ans.CONFIG_DEBUG_KERNEL
2.The first argument passed to printk specifies the
Ans.loglevel for the message to be printed
3.The command that can be used to view the kernel logs from user space is
Ans. dmesg
4. The function create_proc_read_entry returns a pointer to
Ans.struct proc_dir_entry
5.The seq file interface is used for
Ans. Passing kernel information to user space
6. Output of strace shows
Ans. The system calls made by a user application
7. In a kernel oops message EIP points to
Ans. The address of the faulty instruction
8. While using gdb for kernel debugging the kernel core file used passed to gdb is
Ans. /proc/kcore
9.Which of the following keys will launch the kdb
Ans. Pause
10. To use kgdb we need two systems connected by a serial cable
Ans. True
Enabling the traditional Alt+tab function in gnome3
In gnome3 the default bechiaviour of Alt + Tab is different from the traditional gnome behaviour. In gnome3 on pressing alt tab, it displays all the applications that are open, but if more than one window of the same application is open then all the windows are clubbed together and only the application is displayed.
To choose between the windows of the same application we need to wait on the required application or click on it and all the windows of that application gets displayed, and we can click on the window we want to open.
On the other hand the traditional alt tab swithches from one application to next in the order in which they were last used.
If we are not comfortable with this behaviour than we can make gnome perform like the traditions Alt+ tab as shown below.
Click on the activites tab and select the application Advanced Settings by typing "Advanced Settings" which will open a window as shown below.
On the left of the panel of the Advanced settings selec the option "Shell Extension" which will open the window as shown below.
Among the options on the right Turn on the option "Alternate Tab Extension"
Now close the advanced settings and the Alt+tab should start working the traditional fashion now.
To choose between the windows of the same application we need to wait on the required application or click on it and all the windows of that application gets displayed, and we can click on the window we want to open.
On the other hand the traditional alt tab swithches from one application to next in the order in which they were last used.
If we are not comfortable with this behaviour than we can make gnome perform like the traditions Alt+ tab as shown below.
Click on the activites tab and select the application Advanced Settings by typing "Advanced Settings" which will open a window as shown below.
On the left of the panel of the Advanced settings selec the option "Shell Extension" which will open the window as shown below.
Among the options on the right Turn on the option "Alternate Tab Extension"
Now close the advanced settings and the Alt+tab should start working the traditional fashion now.
Subscribe to:
Posts (Atom)