index
- Modify the authority of folder(s) or file(s)
- TAR
- Mount Compile Server
- Run scripts automatically
- Run command in another process without suspend terminal
- find and delete
- find only dir or file to do something
- find text and replace
- remove trailing white spaces
- install openssh-server for remote accessing by others
- scp simple usage
- Concatenate files and output to a new file
- Bluetooth Driver in Fedora 15
- tftp server
- Sourcery Tools Support Portal (Also resolve the problem to run 32-bit excutables on a 64-bit)
- Install Sun Java in Ubuntu 11.04
- Download Directories from FTP use wget
- Components Needed for Fedora 15
- Fedora Group Install Development Tools
- Call a Command, a Program or a Script, then Print the Log to a File
- shortcuts in LXDE
- Fedora 16 NFS Server
- Check pts no. & Communication Between Terminals
- Build RaLink RT3090 WLAN Card Driver Manually (FC16)
- Fedora 16 Fail to Bootup into Graphics Because of NVIDIA Driver
- Fedora 16 Get USB access priority
- Fedora 16 Chrome Shockwave Flash Player Crash
- Fedora 16 Disable SELinux
- Fedora 16 Setup TFTP Server
- Fedora 16 Samba Service
- Make ssh/scp/rsync work Without Password
- Fedora 16 LXDE Keyboard Layout Problem
- Fedora 16 LXDE Desktop Icons Disappear
- Fedora 16 LXDE Desktop Openbox Reload "lxde-rc.xml"
- Fedora 16 Make It Work: Bluetooth Dongle with HC-05 rfcomm
- Restore Files That Was Removed by rm -rf
- Check What Files Are Opened by A Particular Process
- List the First 10 Processes that Consume Most Memory
- Check Net Ports Status
- Create A swapfile for Linux
- Find Regular Files Only (Ignore Directories)
- Sort for Particular Columns
- Delete Specific Line(s) in Some File(s)
- Reading from a continuously changing logfile
Modify the authority of folder(s) or file(s)
1) To modify the ownership of file(s).
$ chown -R USER.NAME OBJ.NAME
2) To modify the group ownership of file(s).
$ chgrp -R GROUP.NAME OBJ.NAME
OR directly like this to change ownership and group at a time:
$ chown -R USER.NAME:GROUP.NAME OBJ.NAME
TAR
1) Extract.
tar xvfj TARBALL.tar.bz2
tar xvfz TARBALL.tar.gz
2) Compress.
tar cvfj TARBALL.tar.bz2 FOLDERtoCOMPRESS
tar cvfz TARBALL.tar.gz FOLDERtoCOMPRESS
Mount Compile Server
Problem description
$ sudo mount -t nfs -o nolock 192.168.1.71:/home/yliao /home/yliao/mnt/compile_server
mount.nfs: access denied by server while mounting 192.168.1.71:/home/yliao
Solution
$ sudo /etc/init.d/nfs-kernel-server start
(NOTE: Run this command on server.)
Run scripts automatically
Just modify this file "/etc/rc.d/rc.local", cause this script will run on each boot up.
Run command in another process without suspend terminal
Add a & just follow the command sequence, such as:
$ gedit xxx.c &
Then there will print a PID repesent that process. When it is finished, there will print some message, too.
find and delete
Delete specific files(dirs). As,
find . -name ".svn" -exec rm -rf {} \;
find only dir or file to do something
chmod only for directories:
find . -type d -exec chmod 755 {} \;
chmod only for files:
find . -type f -exec chmod 644 {} \;
find text and replace
sed -i 's/TO_BE_REPLACED/NEW_STRING/g' FILE_NAME1 FILE_NAME2 ...
and we can also use following line to delete the last line:
sed -i '$d' FILE_NAME
delete the line matches string "chromium":
sed -i '/chromium/d' FILE_NAME
remove trailing white spaces
sed -i 's/[ \t]*$//g' FILE_NAME1 FILE_NAME2 ...
install openssh-server for remote accessing by others
sudo apt-get install openssh-server
scp simple usage
scp yliao@192.168.1.71:/home/yliao/work/marlin4xxu.tar.bz2 .
Concatenate files and output to a new file
cat file1 file2 > newfile
Bluetooth Driver in Fedora 15
The three main command we may use: hciattach, hciconfig, hcitool
$ lsusb
Bus 006 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
$ sudo hciconfig hci0 down
$ sudo hciconfig hci0 up
$ hcitool scan
If succeed, it would be like this:
Scanning ...
00:10:11:07:00:05 HC-05
Then we can use hci to control the Bluetooth Adapter.
tftp server
(on UBUNTU 11.04 32-bit)
1) sudo apt-get install xinetd tftp tftpd-hpa
2) Create a new file /etc/default/tftpd-hpa:
#/etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/opt/tftpboot" TFTP_ADDRESS="192.168.1.130:69" TFTP_OPTIONS="--secure"
3) sudo service tftpd-hpa start
tftpd-hpa start/running, process 17318
That is ok.
4) Testing
tftp 192.168.1.130
tftp> get image_yliao/sm/uImage
Sourcery Tools Support Portal (Also resolve the problem to run 32-bit excutables on a 64-bit)
On Android building, I got: bash: arm-eabi-gcc: no such file or directory
After I resolve the CodeSourcery 64-bit problem, the GTV building can continue.
Maybe just need some packages to install.
Source: https://sourcery.mentor.com/GNUToolchain/kbentry62
What do I need to do to install and run Sourcery CodeBench on an x86 64-bit Linux host system?
In order to use Sourcery CodeBench on an x86 64-bit Linux host system, you must have 32-bit system libraries installed. You can install these 32-bit libraries using your system's package management tool, or build them from source.
Distribution Notes:
Debian/Ubuntu
The following 32-bit libraries are available as packages that can be installed using apt-get on the command line or graphically using Synaptic:
ia32-libs
ia32-libs-gtk (not required for Hardy 8.04 and later)
To install these packages from the command line:
sudo apt-get install ia32-libs ia32-libs-gtk
Next you will need to use Getlibs to install a 32-bit version of xulrunner:
Download getlibs-all.deb
Install getlibs-all.deb by running:
sudo dpkg -i getlibs-all.deb
Install the 32-bit xulrunner by running:
sudo getlibs -p xulrunner-1.9.2
(not necessary)
Setup the IDE to use your recently installed 32-bit xulrunner:
export MOZILLA_FIVE_HOME=/usr/lib32/xulrunner-1.9.2.X
(not necessary)
Substitute X for the version you see installed on your system. You will need to set this environment variable every time you start the IDE.
Red Hat Enterprise Linux
The following 32-bit library is available as a package that can be installed using the up2date command:
glibc-devel
To install this package from the command line:
up2date-nox -i --arch=i386 glibc
Fedora
If working with a new installation of the operating system please run yum update before attempting the following steps.
Logged in as the root user run the following:
Fedora 14:
yum install glibc-devel.i686 gtk2-devel.i686 gtk-nodoka-engine.i686 \
libcanberra.i686 libcanberra-gtk2.i686 PackageKit-gtk-module.i686 \
GConf2.i686 ncurses-libs.i686 xulrunner.i686
Fedora 11:
yum install glibc-devel.i586 gtk2-devel.i586 gtk-nodoka-engine.i586 \
libcanberra.i586 libcanberra-gtk2.i586 PackageKit-gtk-module.i586 \
GConf2.i586 ncurses-libs.i586 xulrunner.i586
Generic Linux
The following 32-bit libraries must be installed with versions greater than or equal to those listed here:
GLIBC 2.3
GTK 2.2.1
ATK 1.2.0
glib 2.2.1
Pango 1.2.1
Freetype 2.1.3
Ncurses 5.0
XULRunner 1.9.1
Install Sun Java in Ubuntu 11.04
Since sun java is not in ubuntu official repo source, we need to add it:
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-jdk
Download Directories from FTP use wget
Such as:
wget ftp://ftp.cn.freebsd.org/pub/FreeBSD/releases/amd64/8.2-RELEASE/* -r
Components Needed for Fedora 15
gnome-tweak-tool
dconf-editor
Fedora Group Install Development Tools
sudo yum groupinstall 'Development Tools'
Call a Command, a Program or a Script, then Print the Log to a File
COMMAND >& FILENAME
e.g.
ls / >& log
Or even the command does not exist, the result "command not found" will also be there:
lk / >& log
shortcuts in LXDE
For now, I just find the only way to modify shortcut keys.
modify this file: /home/USERNAME/.config/openbox/lxde_rc.xml or something alike.
Fedora 16 NFS Server
First of all,
sudo yum install nfs-utils
Then, run
system-config-firewall
In this application, open ports related to nfs: 111, 2049
Next, edit etc/exports
to add the directory you would like to use as nfs, like:
/home/librae/workspace/tq *(rw,sync,no_root_squash)
Operation above can be checked with sudo exportfs -v
After that, go to edit nfs configuration files,
sudo mv /etc/sysconfig/nfs /etc/sysconfig/nfs.bak
sudo mv /etc/sysconfig/nfs.rpmnew /etc/sysconfig/nfs
Then edit /etc/sysconfig/nfs
to include whatever you actually need from /etc/sysconfig/nfs.bak
My /etc/sysconfig/nfs
file:
# # Path to remote quota server. See rquotad(8) #RQUOTAD="/usr/sbin/rpc.rquotad" # Port rquotad should listen on. RQUOTAD_PORT=875 # Optinal options passed to rquotad RPCRQUOTADOPTS="" # # Optional arguments passed to in-kernel lockd #LOCKDARG= # TCP port rpc.lockd should listen on. LOCKD_TCPPORT=32803 # UDP port rpc.lockd should listen on. LOCKD_UDPPORT=32769 # # Optional arguments passed to rpc.nfsd. See rpc.nfsd(8) RPCNFSDARGS="" # Number of nfs server processes to be started. # The default is 8. RPCNFSDCOUNT=8 # Set V4 grace period in seconds #NFSD_V4_GRACE=90 # # Optional arguments passed to rpc.mountd. See rpc.mountd(8) RPCMOUNTDOPTS="" # # Optional arguments passed to rpc.statd. See rpc.statd(8) STATDARG="" # # Optional arguments passed to rpc.idmapd. See rpc.idmapd(8) RPCIDMAPDARGS="" # # Optional arguments passed to rpc.gssd. See rpc.gssd(8) RPCGSSDARGS="" # # Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8) RPCSVCGSSDARGS="" # # To enable RDMA support on the server by setting this to # the port the server should listen on #RDMA_PORT=20049 # # Optional arguments passed to blkmapd. See blkmapd(8) BLKMAPDARGS=""
Well, config ok now, let's enable and start nfs-server service
sudo systemctl enable nfs-server.service
sudo systemctl start nfs-server.service
All done. Reboot computer and use this to verify:
sudo systemctl status nfs-server.service
rpcinfo -p
NOTE!
We MUST ensure these services are running:
systemctl status rpcbind.service systemctl status nfs-server.service systemctl status nfs-lock.service systemctl status nfs-idmap.service
On client machines, we use following command to mount this nfs server, like:
sudo mount -t nfs 192.168.11.6:/home/librae /home/librae/mnt/nbook
Tips:
check nfs service:systemctl -a | grep nfs
nfs config files are located in/etc/sysconfig
external links:
http://www.server-world.info/en/note?os=Fedora_16&p=nfs
http://weisjohn.blog.163.com/blog/#m=0&t=3&c=nfs
http://forums.fedoraforum.org/showthread.php?t=273173
Actually, this version of nfs can be started easily, steps above are redundent.
-
edit
/etc/exports
- start those four services
- All done!
Check pts no. & Communication Between Terminals
ls -hl /proc/self/fd
This will print the pts no. you are on.
e.g.:
yliao@yliao-l-d:~/Public/librae8226.github.com$ ls /proc/self/fd -hl total 0 lrwx------ 1 yliao yliao 64 2011-12-19 15:08 0 -> /dev/pts/10 lrwx------ 1 yliao yliao 64 2011-12-19 15:08 1 -> /dev/pts/10 lrwx------ 1 yliao yliao 64 2011-12-19 15:08 2 -> /dev/pts/10 lr-x------ 1 yliao yliao 64 2011-12-19 15:08 3 -> /proc/1610/fd
Then if we type
echo "Hi there" > /dev/pts/10
See what will happen :P
Build RaLink RT3090 WLAN Card Driver Manually (FC16)
Foreword
--------
Machine: Lenovo B450 (RT3090 Wireless 802.11n 1T/1R PCIe) (use lspci -vnn
to see it)
OS: Fedora 16
Results: Failed to connect my notebook to wifi ap router, but use this driver, we can scan the environment, indeed. That is, it works.
Procedure
---------
-
Download rpm src from RussianFedora: http://koji.russianfedora.ru/koji/buildinfo?buildID=750
-
Extract it and we can see a folder like rt3090-kmod-2.4.0.4-3.fc16.8.R.src
-
Patch all the patches in the folder to src files in 2010_1217_RT3090_LinuxSTA_V2.4.0.4_WiFiBTCombo_DPO.zip
usepatch -p0 xxx.patch
in the .src root folder is just fine.
-
make
-
sudo make install
-
blacklist rt2800, rt28xx drivers in /etc/modprobe.d/blacklist.conf
-
depmod -a ${shell uname -r}
-
reboot
-
bringup:
sudo ifconfig ra0 up
-
scan:
iwlist ra0 scan
-
connect:
sudo iwconfig ra0 essid XXXX
-
longging to further debugging....
Fedora 16 Fail to Bootup into Graphics Because of NVIDIA Driver
Do below steps to remove nvidia driver and enable default noveau driver,
then install nvidia driver again.
su yum remove nvidia* mv /boot/initramfs-$(uname -r)-nouveau.img /boot/initramfs-$(uname -r).img dracut /boot/initramfs-$(uname -r).img $(uname -r) removed "rdblacklist=nouveau nouveau.modeset=0" from GRUB_CMDLINE_LINUX grub2-mkconfig -o /boot/grub2/grub.cfg reboot
Fedora 16 Get USB access priority
sudo usermod -a -G uucp,dialout,lock $USER
Then logout -> login
Fedora 16 Chrome Shockwave Flash Player Crash
Add line below in Chrome script /opt/google/chrome/google-chrome
export LD_PRELOAD=/usr/lib/libGL.so.1
Fedora 16 Disable SELinux
Temporary:
sudo setenforce 0
Always:
vi /etc/sysconfig/selinux
Then set it to disabled
Fedora 16 Setup TFTP Server
sudo yum install tftp* vi /etc/xinetd.d/tftp -------------------------------------------- service tftp { disable = no socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /opt/tftpboot per_source = 11 cps = 100 2 flags = IPv4 } -------------------------------------------- sudo /sbin/chkconfig tftp on sudo systemctl enable xinetd.service sudo systemctl start xinetd.service vi /etc/sysconfig/iptables ---------------------------------------------------------------- -A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT ---------------------------------------------------------------- vi /etc/sysconfig/selinux ---------------- SELINUX=disabled ----------------
Fedora 16 Samba Service
sudo yum install samba samba-client sudo systemctl enable smb.service sudo systemctl start smb.service
Use below command to mount target samba server:
sudo mount.cifs //10.38.120.39/tftpboot /home/yrliao/mnt/tftp_mv -o username=yrliao,password=123456
Make ssh/scp/rsync work Without Password
Make use of a file ~/.ssh/authorized_keys (mode 700) is just fine.
Refer to externel link:
https://blogs.oracle.com/jkini/entry/how_to_scp_scp_and
Fedora 16 LXDE Keyboard Layout Problem
use command below to set it to default, us layout:
setxkbmap us
Fedora 16 LXDE Desktop Icons Disappear
lxde --desktop &
Fedora 16 LXDE Desktop Openbox Reload "lxde-rc.xml"
openbox --reconfigure
Refer to this link:
http://linux-commands.wikidot.com/howto-s:lxde
Fedora 16 Make It Work: Bluetooth Dongle with HC-05 rfcomm
1. Install "blueman".
# yum install blueman
2. Connect Bluetooth dongle and slave HC-05.
3. Search and pair device.
4. Right click HC-05 in blueman, select "Dev B".
Serial port connected to /dev/rfcomm0
5. minicom -s (rfcomm0)
Restore Files That Was Removed by rm -rf
1. Download extundelete from http://extundelete.sourceforge.net/
2. It needs e2fslib, so install them:
# yum install e2fslib*
for Fedora.
# apt-get install e2fslib*
for Ubuntu.
3. Put/excute extundelete in /tmp to avoid unexpected loss.
4. Make sure the filesystem to be restored is unmount. So if it's home, we may use a dual boot OS to do this.
5. Run:
# extundelete --restore-files [OFFSET_PATH_OF_FS] [FS] /* * Such as: * # extundelete --restore-files yrliao/workspace/sandlib/cpu_stat/stat.c /dev/sda6 */
Check What Files Are Opened by A Particular Process
ls -l /proc/7857/fd
List the First 10 Processes that Consume Most Memory
ps -e -o 'pid,comm,args,rsz,vsz,user' | sort -nrk4 | head
Check Net Ports Status
Quotes from man nmap:
The SYN scan and SYN ping (-sS and -PS) are very detailed,
but the TCP connect scan (-sT) is limited by the implementation of the connect system call.
# nmap -sT -O localhost OR # nmap -sS -O localhost
And we can also use this:
$ netstat -lntu
Create A swapfile for Linux
# install -o root -g root -m 0600 /dev/null /swapfile # dd if=/dev/zero of=/swapfile bs=1k count=1024k # mkswap /swapfile # swapon /swapfile # echo "/swapfile swap swap auto 0 0" | tee -a /etc/fstab # sysctl -w vm.swappiness=10 # echo vm.swappiness = 10 | tee -a /etc/sysctl.conf
Referred to: https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880
Find Regular Files Only (Ignore Directories)
e.g in Makefile:
@find $(SRCDIR) -name \*.o -prune -type f | xargs $(RM) @find $(SRCDIR) -name \*.d -prune -type f | xargs $(RM)
Sort for Particular Columns
e.g. in ousia build - sizes file:
cat build/ousia.sizes | sort -k1,1n
0 0 0 0 0 build/core/sys_ds.o 0 0 0 0 0 build/core/sys_ictl.o 0 0 0 0 0 build/framework/vfs/fileops.o 0 0 0 0 0 build/platform/stm32/libmaple/stm32f1/fsmc.o 0 0 0 0 0 build/platform/stm32/libmaple/stm32f1/performance/vector_table.o text data bss dec hex filename 2 0 0 2 2 build/platform/stm32/libmaple/stm32f1/performance/isrs.o 20 0 0 20 14 build/platform/stm32/libmaple/flash.o 20 0 0 20 14 build/platform/stm32/libmaple/gpio.o 20 0 0 20 14 build/platform/stm32/libmaple/pwr.o 24 0 0 24 18 build/core/sys_main.o 24 0 0 24 18 build/platform/stm32/libmaple/start.o 28 0 0 28 1c build/platform/stm32/libmaple/stm32f1/exti.o 36 0 0 36 24 build/platform/stm32/libmaple/usart_private.o 48 0 4 52 34 build/core/sys_sync.o 52 0 0 52 34 build/platform/stm32/libmaple/iwdg.o 56 0 0 56 38 build/platform/stm32/libmaple/usb/usb_lib/usb_init.o 64 0 4 68 44 build/core/sys_time.o 92 0 0 92 5c build/platform/stm32/libmaple/usb/usb_lib/usb_mem.o 96 0 0 96 60 build/platform/stm32/libmaple/exc.o 104 0 0 104 68 build/core/sys_debug.o 104 0 0 104 68 build/platform/stm32/libmaple/dma.o 112 0 0 112 70 build/platform/stm32/libmaple/start_c.o 116 0 0 116 74 build/platform/stm32/libmaple/adc.o 120 0 4 124 7c build/project/sample_stm32/main.o 128 0 0 128 80 build/platform/stm32/libmaple/util_hooks.o 132 24 0 156 9c build/platform/stm32/libmaple/stm32f1/spi.o 140 24 0 164 a4 build/platform/stm32/libmaple/stm32f1/adc.o 144 0 0 144 90 build/platform/stm32/libmaple/nvic.o 152 0 0 152 98 build/platform/stm32/libmaple/rcc.o 188 8 0 196 c4 build/platform/stm32/libmaple/stm32f1/bkp.o 200 0 0 200 c8 build/platform/stm32/libmaple/dac.o 200 0 8 208 d0 build/platform/stm32/libmaple/systick.o 212 32 0 244 f4 build/platform/stm32/libmaple/stm32f1/gpio.o 240 0 0 240 f0 build/platform/stm32/libmaple/spi.o 256 0 0 256 100 build/platform/stm32/libmaple/usb/stm32f1/usb_reg_map.o 288 112 0 400 190 build/platform/stm32/libmaple/stm32f1/i2c.o 344 0 4 348 15c build/core/ulib/string.o 360 0 0 360 168 build/core/sys_mm.o 368 0 0 368 170 build/platform/stm32/libmaple/usart.o 428 0 8 436 1b4 build/platform/stm32/libmaple/util.o 484 252 36 772 304 build/platform/stm32/libmaple/stm32f1/usart.o 520 0 0 520 208 build/core/ulib/stdlib.o 520 20 0 540 21c build/platform/stm32/libmaple/stm32f1/rcc.o 556 0 0 556 22c build/platform/stm32/libmaple/stm32f1/timer.o 572 0 64 636 27c build/project/sample_stm32/eeprom.o 688 0 128 816 330 build/platform/stm32/libmaple/exti.o 784 0 16 800 320 build/core/sys_print.o 868 0 0 868 364 build/framework/console/cmd.o 908 20 0 928 3a0 build/platform/stm32/libmaple/usb/stm32f1/usb.o 928 164 0 1092 444 build/platform/stm32/libmaple/timer.o 1060 0 464 1524 5f4 build/framework/console/console.o 1188 0 36 1224 4c8 build/core/sys_utils.o 1276 4 1 1281 501 build/platform/stm32/utils/utils.o 1304 68 0 1372 55c build/platform/stm32/libmaple/stm32f1/dma.o 1460 0 0 1460 5b4 build/core/mm_std.o 1600 192 86 1878 756 build/platform/stm32/libmaple/usb/stm32f1/usb_cdcacm.o 1776 0 0 1776 6f0 build/platform/stm32/libmaple/i2c.o 1852 0 16 1868 74c build/platform/stm32/port/ousia_port.o 1968 0 0 1968 7b0 build/platform/stm32/libmaple/usb/usb_lib/usb_regs.o 2344 0 1 2345 929 build/platform/stm32/libmaple/usb/usb_lib/usb_core.o 2544 0 2048 4592 11f0 build/project/sample_stm32/mlcd.o 2556 0 36 2592 a20 build/core/sys_sched.o 32674 920 2964 36558 8ece (TOTALS)
Delete Specific Line(s) in Some File(s)
Those lines contains "sm_api.h" will be deleted.
sed -i '/sm_api\.h/d' `find . -name \*.c`
Reading from a continuously changing logfile
In below case, btsnoop_hci.log.txt is growing:
tail -f /sdcard/btsnoop_hci.log.txt