linux 小记3

Posted hebbely

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 小记3相关的知识,希望对你有一定的参考价值。

1.U盘

1> linux – /sys中的SCSI设备条目与/dev中的磁盘之间的对应关系

获取通信的简单方法是查看/ sys层次结构中的device / block子目录:

root@imx6dlsabresd:~# ls -1d /sys/class/scsi_device/*/device/block/*
/sys/class/scsi_device/0:0:0:0/device/block/sda
root@imx6dlsabresd:~# 

2> 是否插入U盘

/**
 * @brief usb_stroage
 *  返回1表示已插入U盘,返回0表示未插入U盘
 * @return
 */
int usb_stroage(void)

    QDir udir;
    udir.setPath("/sys/class/scsi_device/");
    if((udir.exists()) && (udir.entryInfoList().count() > 2))
    
        return 1;
    
    return 0;

3> 通过fdisk磁盘分区查找U盘

/sbin/fdisk -l | grep sda
/sbin/fdisk -l | grep sdb
/sbin/fdisk -l | grep sdc
/sbin/fdisk -l | grep sdd
/sbin/fdisk -l | grep sde

4>挂载

root@imx6dlsabresd:/etc# cat mount-usb.sh 
#!/bin/sh
mkdir /udisk -p
mount -t vfat /dev/$1 /udisk
sync
root@imx6dlsabresd:/etc# 
root@imx6dlsabresd:/etc# cat umount-usb.sh 
#!/bin/sh
sync
umount /udisk
rm /udisk -rf
root@imx6dlsabresd:/etc# 

2. amixer

alsamixer是Linux 音频架构ALSA中的Alsa工具的其中一个,用于配置音频的各个参数。
alsamixer是基于文本下的图形界面的,可以通过键盘的上下键,左右键等,很方便地设置需要的音量,开关某个switch(开关)等等操作。
amixer,是alsamixer的文本模式,即命令行模式,需要用amixer命令的形式去配置你的声卡的各个选项。

amixer --helpamixer --help看看amixer支持哪些命令
amixer controlsamixer controls显示所有的音频控件
amixer contentsamixer contents显示所有的音频控件的内容
amixer cget amixer cget numid=13获取一个音频控件的内容
amixer csetamixer cset numid=10 240设置一个音频控件的内容
amixer scontrolsamixer scontrols显示所有混音器控件
amixer scontentsamixer scontents显示所有混音器控件的内容
amixer sgetamixer sget获取一个混音器控件的内容
amixer setamixer sset设置一个混音器控件的内容

1> amixer --help (看看amixer支持哪些命令)

root@imx6dlsabresd:~# amixer --help
Usage: amixer <options> [command]

Available options:
  -h,--help       this help
  -c,--card N     select the card
  -D,--device N   select the device, default 'default'
  -d,--debug      debug mode
  -n,--nocheck    do not perform range checking
  -v,--version    print version of this program
  -q,--quiet      be quiet
  -i,--inactive   show also inactive controls
  -a,--abstract L select abstraction level (none or basic)
  -s,--stdin      Read and execute commands from stdin sequentially
  -R,--raw-volume Use the raw value (default)
  -M,--mapped-volume Use the mapped volume

Available commands:
  scontrols       show all mixer simple controls
  scontents       show contents of all mixer simple controls (default command)
  sset sID P      set contents for one mixer simple control
  sget sID        get contents for one mixer simple control
  controls        show all controls for given card
  contents        show contents of all controls for given card
  cset cID P      set control contents for one control
  cget cID        get control contents for one control
root@imx6dlsabresd:~# 

2> 查看当前的音频系统

amixer controls
amixer contents

root@imx6dlsabresd:~# amixer controls
numid=58,iface=CARD,name='Headphone Jack'
numid=12,iface=MIXER,name='Headphone Playback ZC Switch'
numid=11,iface=MIXER,name='Headphone Playback Volume'
numid=17,iface=MIXER,name='PCM Playback -6dB Switch'
numid=42,iface=MIXER,name='Mono Output Mixer Left Switch'
numid=43,iface=MIXER,name='Mono Output Mixer Right Switch'
numid=41,iface=MIXER,name='ADC Data Output Select'
numid=19,iface=MIXER,name='ADC High Pass Filter Switch'
numid=36,iface=MIXER,name='ADC PCM Capture Volume'
numid=18,iface=MIXER,name='ADC Polarity'
numid=2,iface=MIXER,name='Capture Volume ZC Switch'
numid=3,iface=MIXER,name='Capture Switch'
numid=1,iface=MIXER,name='Capture Volume'
numid=10,iface=MIXER,name='Playback Volume'
numid=23,iface=MIXER,name='3D Filter Lower Cut-Off'
numid=22,iface=MIXER,name='3D Filter Upper Cut-Off'
numid=25,iface=MIXER,name='3D Switch'
numid=24,iface=MIXER,name='3D Volume'
numid=33,iface=MIXER,name='ALC Attack'
numid=32,iface=MIXER,name='ALC Decay'
numid=26,iface=MIXER,name='ALC Function'
numid=30,iface=MIXER,name='ALC Hold Time'
numid=27,iface=MIXER,name='ALC Max Gain'
numid=29,iface=MIXER,name='ALC Min Gain'
numid=31,iface=MIXER,name='ALC Mode'
numid=28,iface=MIXER,name='ALC Target'
numid=21,iface=MIXER,name='DAC Deemphasis Switch'
numid=20,iface=MIXER,name='DAC Polarity'
numid=57,iface=MIXER,name='Left Boost Mixer LINPUT1 Switch'
numid=55,iface=MIXER,name='Left Boost Mixer LINPUT2 Switch'
numid=56,iface=MIXER,name='Left Boost Mixer LINPUT3 Switch'
numid=9,iface=MIXER,name='Left Input Boost Mixer LINPUT1 Volume'
numid=7,iface=MIXER,name='Left Input Boost Mixer LINPUT2 Volume'
numid=6,iface=MIXER,name='Left Input Boost Mixer LINPUT3 Volume'
numid=51,iface=MIXER,name='Left Input Mixer Boost Switch'
numid=49,iface=MIXER,name='Left Output Mixer Boost Bypass Switch'
numid=37,iface=MIXER,name='Left Output Mixer Boost Bypass Volume'
numid=48,iface=MIXER,name='Left Output Mixer LINPUT3 Switch'
numid=38,iface=MIXER,name='Left Output Mixer LINPUT3 Volume'
numid=47,iface=MIXER,name='Left Output Mixer PCM Playback Switch'
numid=35,iface=MIXER,name='Noise Gate Switch'
numid=34,iface=MIXER,name='Noise Gate Threshold'
numid=54,iface=MIXER,name='Right Boost Mixer RINPUT1 Switch'
numid=52,iface=MIXER,name='Right Boost Mixer RINPUT2 Switch'
numid=53,iface=MIXER,name='Right Boost Mixer RINPUT3 Switch'
numid=8,iface=MIXER,name='Right Input Boost Mixer RINPUT1 Volume'
numid=5,iface=MIXER,name='Right Input Boost Mixer RINPUT2 Volume'
numid=4,iface=MIXER,name='Right Input Boost Mixer RINPUT3 Volume'
numid=50,iface=MIXER,name='Right Input Mixer Boost Switch'
numid=46,iface=MIXER,name='Right Output Mixer Boost Bypass Switch'
numid=39,iface=MIXER,name='Right Output Mixer Boost Bypass Volume'
numid=44,iface=MIXER,name='Right Output Mixer PCM Playback Switch'
numid=45,iface=MIXER,name='Right Output Mixer RINPUT3 Switch'
numid=40,iface=MIXER,name='Right Output Mixer RINPUT3 Volume'
numid=16,iface=MIXER,name='Speaker AC Volume'
numid=15,iface=MIXER,name='Speaker DC Volume'
numid=13,iface=MIXER,name='Speaker Playback Volume'
numid=14,iface=MIXER,name='Speaker Playback ZC Switch'
root@imx6dlsabresd:~# 
root@imx6dlsabresd:~# amixer contents
numid=58,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=12,iface=MIXER,name='Headphone Playback ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=off,off
numid=11,iface=MIXER,name='Headphone Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=101,101
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=17,iface=MIXER,name='PCM Playback -6dB Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=42,iface=MIXER,name='Mono Output Mixer Left Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=43,iface=MIXER,name='Mono Output Mixer Right Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=41,iface=MIXER,name='ADC Data Output Select'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Left Data = Left ADC;  Right Data = Right ADC'
  ; Item #1 'Left Data = Left ADC;  Right Data = Left ADC'
  ; Item #2 'Left Data = Right ADC; Right Data = Right ADC'
  ; Item #3 'Left Data = Right ADC; Right Data = Left ADC'
  : values=1
numid=19,iface=MIXER,name='ADC High Pass Filter Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=36,iface=MIXER,name='ADC PCM Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=255,step=0
  : values=195,195
  | dBscale-min=-97.50dB,step=0.50dB,mute=1
numid=18,iface=MIXER,name='ADC Polarity'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'No Inversion'
  ; Item #1 'Left Inverted'
  ; Item #2 'Right Inverted'
  ; Item #3 'Stereo Inversion'
  : values=0
numid=2,iface=MIXER,name='Capture Volume ZC Switch'
  ; type=INTEGER,access=rw------,values=2,min=0,max=1,step=0
  : values=0,0
numid=3,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0
  : values=35,35
  | dBscale-min=-17.25dB,step=0.75dB,mute=0
numid=10,iface=MIXER,name='Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=255,step=0
  : values=230,230
  | dBscale-min=-127.50dB,step=0.50dB,mute=1
numid=23,iface=MIXER,name='3D Filter Lower Cut-Off'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'Low'
  ; Item #1 'High'
  : values=0
numid=22,iface=MIXER,name='3D Filter Upper Cut-Off'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'High'
  ; Item #1 'Low'
  : values=0
numid=25,iface=MIXER,name='3D Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=24,iface=MIXER,name='3D Volume'
  ; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
  : values=0
numid=33,iface=MIXER,name='ALC Attack'
  ; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
  : values=2
numid=32,iface=MIXER,name='ALC Decay'
  ; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
  : values=3
numid=26,iface=MIXER,name='ALC Function'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Off'
  ; Item #1 'Right'
  ; Item #2 'Left'
  ; Item #3 'Stereo'
  : values=0
numid=30,iface=MIXER,name='ALC Hold Time'
  ; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
  : values=0
numid=27,iface=MIXER,name='ALC Max Gain'
  ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0
  : values=7
numid=29,iface=MIXER,name='ALC Min Gain'
  ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0
  : values=0
numid=31,iface=MIXER,name='ALC Mode'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'ALC'
  ; Item #1 'Limiter'
  : values=0
numid=28,iface=MIXER,name='ALC Target'
  ; type=INTEGER,access=rw------,values=1,min=0,max=15,step=0
  : values=4
numid=21,iface=MIXER,name='DAC Deemphasis Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=20,iface=MIXER,name='DAC Polarity'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'No Inversion'
  ; Item #1 'Left Inverted'
  ; Item #2 'Right Inverted'
  ; Item #3 'Stereo Inversion'
  : values=0
numid=57,iface=MIXER,name='Left Boost Mixer LINPUT1 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=55,iface=MIXER,name='Left Boost Mixer LINPUT2 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=56,iface=MIXER,name='Left Boost Mixer LINPUT3 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=9,iface=MIXER,name='Left Input Boost Mixer LINPUT1 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=3,step=0
  : values=0
  | dBrange-
    rangemin=0,,rangemax=1
      | dBscale-min=0.00dB,step=13.00dB,mute=0
    rangemin=2,,rangemax=3
      | dBscale-min=20.00dB,step=9.00dB,mute=0

numid=7,iface=MIXER,name='Left Input Boost Mixer LINPUT2 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=0
  | dBscale-min=-15.00dB,step=3.00dB,mute=1
numid=6,iface=MIXER,name='Left Input Boost Mixer LINPUT3 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=0
  | dBscale-min=-15.00dB,step=3.00dB,mute=1
numid=51,iface=MIXER,name='Left Input Mixer Boost Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=49,iface=MIXER,name='Left Output Mixer Boost Bypass Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=37,iface=MIXER,name='Left Output Mixer Boost Bypass Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=2
  | dBscale-min=-21.00dB,step=3.00dB,mute=0
numid=48,iface=MIXER,name='Left Output Mixer LINPUT3 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=38,iface=MIXER,name='Left Output Mixer LINPUT3 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=2
  | dBscale-min=-21.00dB,step=3.00dB,mute=0
numid=47,iface=MIXER,name='Left Output Mixer PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=35,iface=MIXER,name='Noise Gate Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=34,iface=MIXER,name='Noise Gate Threshold'
  ; type=INTEGER,access=rw------,values=1,min=0,max=31,step=0
  : values=0
numid=54,iface=MIXER,name='Right Boost Mixer RINPUT1 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=52,iface=MIXER,name='Right Boost Mixer RINPUT2 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=53,iface=MIXER,name='Right Boost Mixer RINPUT3 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=8,iface=MIXER,name='Right Input Boost Mixer RINPUT1 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=3,step=0
  : values=0
  | dBrange-
    rangemin=0,,rangemax=1
      | dBscale-min=0.00dB,step=13.00dB,mute=0
    rangemin=2,,rangemax=3
      | dBscale-min=20.00dB,step=9.00dB,mute=0

numid=5,iface=MIXER,name='Right Input Boost Mixer RINPUT2 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=0
  | dBscale-min=-15.00dB,step=3.00dB,mute=1
numid=4,iface=MIXER,name='Right Input Boost Mixer RINPUT3 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=0
  | dBscale-min=-15.00dB,step=3.00dB,mute=1
numid=50,iface=MIXER,name='Right Input Mixer Boost Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=46,iface=MIXER,name='Right Output Mixer Boost Bypass Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=39,iface=MIXER,name='Right Output Mixer Boost Bypass Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=2
  | dBscale-min=-21.00dB,step=3.00dB,mute=0
numid=44,iface=MIXER,name='Right Output Mixer PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=45,iface=MIXER,name='Right Output Mixer RINPUT3 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=40,iface=MIXER,name='Right Output Mixer RINPUT3 Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
  : values=2
  | dBscale-min=-21.00dB,step=3.00dB,mute=0
numid=16,iface=MIXER,name='Speaker AC Volume'
  ; type=INTEGER,access=rw------,values=1,min=0,max=5,step=0
  : values=5
numid=15,iface=MIXER,name='Speaker DC Volume'
  ; type=INTEGER,access=rw------,values=1,min=0,max=5,step=0
  : values=5
numid=13,iface=MIXER,name='Speaker Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=127,127
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=14,iface=MIXER,name='Speaker Playback ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=off,off
root@imx6dlsabresd:~# 
root@imx6dlsabresd:~# amixer cget numid=13
numid=13,iface=MIXER,name='Speaker Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=127,127
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
root@imx6dlsabresd:~# amixer cget numid=10
numid=10,iface=MIXER,name='Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=255,step=0
  : values=230,230
  | dBscale-min=-127.50dB,step=0.50dB,mute=1
root@imx6dlsabresd:~# 

以上是关于linux 小记3的主要内容,如果未能解决你的问题,请参考以下文章

linux 小记3

无标题linux 小记3

Linux服务器之lrzsz命令小记

Linux服务器之lrzsz命令小记

Linux服务器之lrzsz命令小记

Linux 命令小记:dmesg命令