2014. október 4., szombat

Linux cheats

Linux cheats


1.Install kernel headers from source
make headers_install


2. Cross complie



make modules ARCH=arm KLIB=/home/peti/Desktop/build/linux-3.2 KLIB_BUILD=/home/peti/Desktop/build/linux-3.2 CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
make modules


make modules ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-


make install ARCH=arm DESTDIR=/home/peti/Desktop/build/wifi KLIB=/home/peti/Desktop/build/linux-3.2 KLIB_BUILD=/home/peti/Desktop/build/linux-3.2 CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-


apt-get install u-boot
wget -O arch/arm/tools/mach-types http://www.arm.linux.org.uk/developer/machines/download.php
make ARCH=arm uImage modules


3. Get linux version

cat /proc/version
Linux version 3.2.0 (peter@Ubuntu) (gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) ) #8 Fri Feb 3 18:26:06 CET 2012


4. List Logs

-List Kernel Log
dmesg   
-List system log
less /var/log/messages


5. TAR extract/compress

5.1. extract tar.gz
tar -zxvf backup.tar.gz
5.2. extract tar.gz2
tar -xjf test.tar.bz2


6. Kernel complining

make clean
make mrproper" is a command in the Linux kernel build system
make modules ARCH=arm KLIB=/lib/modules/3.2.0/build  KLIB_BUILD=/lib/modules/3.2.0/build


7.  Kilistázza az összes wireless-el kapcsolatos csomagot

apt-cache search wireless
dpkg --get-selections   -kilistázza a feltelepített csomagokat
aptitude -kilistázza a feltelepített csomagokat GUI-val
dpkg -l  -List installed package




7.1WIFI settings

iwconfig wlan0 mode Managed
iwconfig wlan0 essid Virusos
iwconfig wlan0 key off
iwconfig wlan0 channel auto
iwconfig wlan0 key s:Foxi82Zeusz
iwconfig wlan0 freq 2.422G
iwconfig wlan0 rate auto
ifconfig wlan0 up
ifup wlan0


8. Characteres GUI ami a CPU usage-t mutatja

top -command


9. List all users

cat /etc/passwd or cat /etc/passwd | grep home


10. Torrent

transmission-remote --auth debian-transmission:******* -l


To add a torrent to the daemon, use this command:
transmission-remote -a [path to file].torrent
Start all torrents:
transmission-remote -s all
Stop all torrents:
transmission-remote -S all
Start a specific torrent:
transmission-remote -s [hash]
Stop a specific torrent:
transmission-remote -S [hash]
Remove all torrents:
transmission-remote -r all
Remove a specific torrent:
transmission-remote -r [hash]
Get hashes for all torrents:
transmission-remote -i
List all torrents with status:
transmission-remote -l
Quit the daemon:
transmission-remote -q


11. Mediatomb UPNP

more /var/log/mediatomb.log
/etc/mediatomb/config.xml
sudo service mediatomb restart


12. List all using ports

netstat -lp


13. List process and sort by memory usage

ps aux --sort -rss
sort by CPU usage
ps aux --sort -%cpu

14.  WiringPI-t használó prg forditása

gcc ./dcmotor.c -o dcmotor  -L/usr/local/lib -lwiringPi


c++ ./dcmotor.c -o dcmotor  -L/usr/local/lib -lwiringPi


15. Add startup service (init.d)

1. Copy the installdir/ctlscript.sh file to /etc/init.d . It is advisable to rename this script to something more specific, like “bitnami-drupal”.
cp ${installdir}/ctlscript.sh /etc/init.d/bitnami-drupal


2. We will use rc-update.d to add the script to the defaults runlevels.
update-rc.d -f bitnami-drupal defaults

And that’s it, the servers will be loaded at boot time. To revert the changes, just type
update-rc.d -f bitnami-drupal remove


16. CRONTAB

/etc/init.d/cron restart
crontab -e   -> létező beállitás szerkesztése
*************BEÁLLÍTSA HA MÉG NINCS***********************************************************
Create a file, say cron.txt, with exactly the following contents (1 line):


* * * * * touch $HOME/CRON_IS_RUNNING
(Do not create CRON_IS_RUNNING manually.) Run


crontab cron.txt
which should quietly produce no output, then


crontab -l
which should print


* * * * * touch $HOME/CRON_IS_RUNNING
Wait a minute or so, perhaps 2 minutes, then


ls -l $HOME/CRON_IS_RUNNING
which should print something like


-rw-r--r-- 1 yourname yourgroup 0 2011-08-23 20:11 CRON_IS_RUNNING
If this all works, it will confirm that you can run cron jobs.


*********************************************************************************************
16.1 CRONTAB
Daily reboot
0 22 * * * /sbin/shutdown -r now


17. Change time zone

dpkg-reconfigure tzdata

18. SSHD log

/var/log/auth.log

19. Linux add a new user called reka

useradd -s /bin/sh -m -d /home/reka -c "Juhasz Reka" -g root reka


System Statistic


1. Install
sudo apt-get install sysstat


nano /etc/cron.d/sysstat
1 * * * * root /usr/lib/sysstat/sa1 1 1
53 23 * * * root /usr/lib/sysstat/ -A


crontab /etc/cron.d/sysstat


crontab -l


2. Display report


CPU usage report
sar -u
Memory usage report
sar -r
Swap space usage report
sar -S
Overall I/O Activities
sar -b
Network statistic
sar -n ALL


DISPLAY GRAPH with PHP


20.File associations



nano ~/.local/share/applications/mimeapps.list
sudo update-desktop-database


nano /usr/share/applications/defaults.list


21.Transmission settings

https://trac.transmissionbt.com/wiki/Scripts/initd


chmod +x /etc/init.d/transmission-daemon
chown root:root /etc/init.d/transmission-daemon
$ adduser --disabled-password debian-transmission


transmission-daemon -f -t -u debian-transmission -v Start12345678 -w /home/debian-transmission/torrents -g /etc/transmission-daemon/


"rpc-whitelist": "127.0.0.*,192.168.1.*"
---------------
sudo /etc/init.d/transmission-daemon stop


sudo vim /etc/default/transmission-daemon


Set the CONFIG_DIR variable to point to the folder that contains your settings. e.g, :


CONFIG_DIR="/etc/transmission-daemon"


Save the file. Next, type:


sudo vim /etc/init.d/transmission-daemon


Set the USER variable to the same name as above, e.g., "username" in this example. Also, you don't need the -g option in NAME any more. The first three lines /etc/init.d/transmission-daemon should now look like this:


NAME=transmission-daemon
DAEMON=/usr/bin/$NAME
USER=username


Save your changes, then
------------------------------------


22. User permission

Raspberry PI


***************************WIFI***************************************
File: /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid Virusos
wpa-psk xxxxxxxxxxxx
*********************************************************************
Port Forward in router
1 22 192.168.1.101 ALL Enabled Modify Delete
2 5555 192.168.1.101 ALL Enabled Modify Delete
4 51413 192.168.1.101 ALL Enabled Modify Delete
5 2222 192.168.1.103 ALL Enabled Modify Delete  -LAN
6 4000 192.168.1.105 ALL Enabled Modify Delete -WIFI
7 443 192.168.1.105 ALL Enabled Modify Delete -WIFI
3 6111 192.168.1.105 ALL Enabled Modify Delete -WIFI
Configure in PI
sudo nano /etc/ssh/sshd_config
Port 4000
Port 2222
*********************************************************************
To enable the root account, login to your raspberry pi, then type "sudo -i" and hit Return / Enter. (you'll need to type your password in).
Then type "passwd root" and hit Return / Enter.
You will be asked to type a password, then confirm it.
It will say that the password was successfully changed.
Now you need to completely log out of your Raspberry Pi (Restarting it works as well :D), then login with:
Username: root
Password: Whatever you just set
********************************************************************
Mjpg strem install and start boot time


**********************
UltraSHONIC


takepic.sh
#!/bin/sh
fswebcam -r 1600x1200 -p MJPEG --jpeg 85 --no-banner --no-timestamp --no-title -D 1 /tmp/web-cam-shot2MJPEG.jpg --loop 10 --exec /root/kepek/movepic.sh


movepic.sh
#!/bin/sh
filename=`date '+%m%d%y%h%m%s'`
mv /tmp/web-cam-shot2MJPEG.jpg /root/kepek/${filename}.jpg


PDF resizer



pdf2ps large.pdf very_large.ps
ps2pdf very_large.ps small.pdf
Results
large.pdf : 6.3MB
very_large.ps : 53.4MB
small.pdf : 2.4MB
Looks like pretty good compression to me

Nincsenek megjegyzések:

Megjegyzés küldése