Created
July 13, 2019 10:40
-
-
Save omair18/dc361c32aacbdb67dba156d4bb938222 to your computer and use it in GitHub Desktop.
Various useful Linux commands for daily usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#to check video card working right now | |
sudo lshw -C video | |
#!/bin/bash | |
# to know which device is connected at which port | |
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do | |
( | |
syspath="${sysdevpath%/dev}" | |
devname="$(udevadm info -q name -p $syspath)" | |
[[ "$devname" == "bus/"* ]] && continue | |
eval "$(udevadm info -q property --export -p $syspath)" | |
[[ -z "$ID_SERIAL" ]] && continue | |
echo "/dev/$devname - $ID_SERIAL" | |
) | |
done | |
#detailed hardware | |
lspci | |
sudo add-apt-repository ppa:linrunner/tlp | |
sudo add-apt-repository ppa:yannubuntu/boot-repair | |
#manually install grub | |
sudo mount /dev/sdX# /mnt | |
sudo grub-install --boot-directory=/mnt/boot /dev/sdX | |
#UUID Of drives | |
sudo blkid | |
#suspend issues | |
echo "mem" | sudo tee "/sys/power/state" | |
echo "inspiron;" | sudo -S echo && echo "mem" | sudo tee "/sys/power/state" | |
#install mate desktop in ubuntu | |
sudo apt-add-repository ppa:ubuntu-mate-dev/ppa | |
sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate | |
sudo apt-get update && sudo apt-get upgrade | |
sudo apt-get install --no-install-recommends ubuntu-mate-core ubuntu-mate-desktop | |
#AMD drivers ubuntu | |
sudo apt-get purge fglrx* | |
sudo apt-get install fglrx xvba-va-driver libva-glx1 libva-egl1 vainfo | |
sudo amdconfig --initial | |
#install FFMPEG in ubuntu | |
sudo add-apt-repository ppa:mc3man/trusty-media | |
sudo apt-get update | |
sudo apt-get install ffmpeg | |
## rotate images | |
convert -rotate 90 frame0.jpg frame0.jpg | |
#crop images into equal parts | |
convert -crop 20% rose.jpg rose_%d.jpg | |
#crop video time | |
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4 | |
#whatsapp video format | |
"ffmpeg -i vlc-record-2018-08-16-20h28m10s-MVI_0006.AVI-.avi -c:v libx264 -profile:v baseline -level 5.0 -pix_fmt yuv420p working.mp4" | |
## rotate video | |
ffmpeg VID_20180508_021953.mp4 -strict -2 -vf "transpose=2" blue1.mp4 | |
#0,1,2,3 | |
#create GIF file from video | |
ffmpeg -ss 00:00:01 -i turtle2.mp4 -to 20 -r 5 -vf scale=1200:-1 turtle2.gif | |
# convert video to low resolution | |
mencoder input.mp4 -ovc lavc -lavcopts vcodec=mp4 -vf scale=640:480 -oac copy -o output.mp4 | |
mencoder Bikes.avi -ovc x264 -lavcopts vcodec=mp4 -vf scale=320:240 -oac copy -o outputScaled.mp4 | |
mencoder input.mp4 -vop scale=640:480 -o output.mp4 | |
#download a file from Github repoistory | |
bash < <(curl --silent https://raw.github.com/thenovices/dotfiles/master/install.sh) | |
#download directory from http link | |
wget -r --no-parent http://abc.tamu.edu/projects/tzivi/repository/revisions/2/raw/tzivi/ | |
#parse filenames in a folder | |
for i in *.JPG | |
do | |
x=`cut -d'_' -f1 <<< "$i"` | |
echo $x | |
mv "$i" "$x" | |
done | |
# rename files in a folder | |
x=255 | |
for i in *.JPG | |
do | |
echo $x | |
mv "$i" "$x".jpg | |
x=$((x+1)) | |
done | |
######################3 | |
for i in *.jpg | |
do | |
x=`cut -d'_' -f1 <<< "$i"` | |
echo $x | |
mv "$i" "$x" | |
done | |
###########################3 | |
for i in *.png; | |
do | |
x=`cut -d'.' -f1 <<< "$i"`; | |
echo $x; convert $i "$x.jpg"; | |
rm $i | |
done | |
##########################find duplicate images | |
fdupes -r1 PicturesData/ > dup.txt | |
fdupes PicturesData/ -R -f1 PicturesData/Camera\ Uploads/ | |
######################### read file line by line | |
#!/bin/bash | |
shopt -s nullglob | |
input="dupes_what.txt" | |
while IFS= read -r var | |
do | |
mv "$var" temp_wht_img/ | |
echo $var | |
done < "$input" | |
#$ find Pictures/ -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > dupes.txt | |
######### find and list files with specific size. | |
find . -type f -size 1702c | xargs rm | |
######################## check size | |
sztotal=0 | |
for i in `ls` | |
do | |
szdetail=`du $i` | |
sz=$(echo $szdetail | cut -d' ' -f1) | |
sztotal=$((sztotal+sz)) | |
echo $i $sz | |
done | |
echo "Total size = " $sztotal | |
###################### grab filename from path | |
path=/this/is/could/be/any/path/abc.txt | |
file=$(basename $path) | |
Or | |
file=${path##*/} | |
####################### ANDROID LOGCAT | |
adb -d logcat com.example.example:I *:S | |
#######################add a backslash before all spaces of a file? | |
echo "$line" | sed 's/ /\\ /g' | |
#insert text at start of each line | |
sed 's/^/[/' abcde.txt >abcdef.txt | |
#insert tex at end of each line of file | |
sed 's/$/&],/' 2011_data_missing.txt >abcde.txt | |
####################### decimate file into a new file | |
awk 'NR % 50 == 0' < FILE > output.txt | |
#To make Ubuntu do nothing when laptop lid is closed: | |
#Open the /etc/systemd/logind.conf file in a text editor as root, for example, | |
sudo -H gedit /etc/systemd/logind.conf | |
#######################Add a line HandleLidSwitch=ignore (make sure it's not commented out!), | |
#######################Restart the systemd daemon with this command: | |
sudo restart systemd-logind | |
#remove extension from filename | |
filename="${filename%.*}" | |
extension="${filename##*.}" | |
###################### install cinnamon3.2 | |
sudo add-apt-repository ppa:embrosyn/cinnamon | |
###################### restart cinnamon | |
pkill -HUP -f "cinnamon --replace" | |
xfce4-panel -r & | |
new number | |
+4915218119427 | |
#pclviewer with normals | |
pcl_viewer mwk.pcd -normals_scale 2 -normals 1 | |
#CloudCompare -SILENT -M_EXPORT_FMT PLY -PLY_EXPORT_FMT ASCII -O bed_0002.off -SAMPLE_MESH POINTS 100000 | |
#CloudCompare -SILENT -O bed_0005.off -SAMPLE_MESH POINTS 100000 -M_EXPORT_FMT PLY -PLY_EXPORT_FMT ASCII -NO_TIMESTAMP #-SAVE_MESHES | |
CloudCompare -SILENT -O bed_0001.off -SAMPLE_MESH POINTS 1000 -C_EXPORT_FMT PLY -PLY_EXPORT_FMT ASCII -NO_TIMESTAMP -SAVE_CLOUDS | |
#CloudCompare -O bed_0004_SAMPLED_POINTS_2016-06-27_21h36_58.bin -SILENT -C_EXPORT_FMT PLY -SAVE_CLOUDS -NO_TIMESTAMP | |
#########################3 #import PCL project in eclipse | |
cmake -G "Eclipse CDT4 - Unix Makefiles" ../src/ | |
sudo add-apt-repository ppa:nilarimogard/webupd8 | |
#######################3#proxy settings in terminal | |
export http_proxy='http://172.20.0.7:3128' | |
export https_proxy='https://172.20.0.7:3128' | |
#/etc/apt/apt.conf | |
Acquire::http::proxy "http://172.20.0.7:3128/"; | |
Acquire::https::proxy "https://172.20.0.7:3128/"; | |
######################### #cat contents of file as soon as updated | |
tail -f log.txt | |
########################3 #redirect caffe's output ( stderr) to file | |
caffe > log.txt 2>&1 | |
# caffe python layers ubuntu 16.04 | |
pip install protobuf==3.1.0 | |
############################# #merge pdfs | |
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf | |
pdftk file1.pdf file2.pdf cat output mergedfile.pdf | |
#tmate | |
sudo add-apt-repository ppa:tmate.io/archive && \ | |
sudo apt-get update && \ | |
sudo apt-get install tmate | |
tmate -S /tmp/tmate.sock new-session -d # Launch tmate in a detached state | |
tmate -S /tmp/tmate.sock wait tmate-ready # Blocks until the SSH connection is established | |
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}' # Prints the SSH connection string | |
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh_ro}' # Prints the read-only SSH connection string | |
tmate -S /tmp/tmate.sock display -p '#{tmate_web}' # Prints the web connection string | |
tmate -S /tmp/tmate.sock display -p '#{tmate_web_ro}' # Prints the read-only web connection string | |
#CVLAB | |
ssh [email protected] | |
https://tmate.io/t/ov8Vx7tVyAIyxGCZfBF32N6br | |
#GIT COMMIT from LOCAL disk | |
git add <file-1> <file-2> <etc> | |
Commit with | |
git commit -m'<your-message>' | |
git commit | |
git push | |
10.103.72.48 | |
#theano lasagne nolearn | |
sudo pip install -r https://raw.githubusercontent.com/dnouri/nolearn/master/requirements.txt git+https://github.com/dnouri/nolearn.git@master#egg=nolearn==0.7.git | |
#voxnet | |
pip install --editable . | |
#convert stereo mp3 to mono | |
lame --decode input.mp3 - | lame -m m -V2 - output.mp3 | |
#cloudcompare | |
echo "deb https://dl.bintray.com/ornis/CloudCompare trusty main" | sudo tee -a /etc/apt/sources.list | |
#pcl prebuild | |
deb http://ppa.launchpad.net/v-launchpad-jochen-sprickerhof-de/pcl/ubuntu trusty main | |
deb-src http://ppa.launchpad.net/v-launchpad-jochen-sprickerhof-de/pcl/ubuntu trusty main | |
# replace word in all files | |
sed -i 's/old-word/new-word/g' *.txt | |
#switch nvidia graphic card | |
prime-select nvidia/intel | |
wget -qO - http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/7fa2af80.pub | sudo apt-key add - | |
#nvidia graphic card bootoption | |
nomodeset xforcevesa | |
ppa:graphics-drivers/ppa | |
## jasper | |
wget http://security.ubuntu.com/ubuntu/pool/main/j/jasper/libjasper-dev_1.900.1-debian1-2.4ubuntu1.2_amd64.deb | |
wget http://security.ubuntu.com/ubuntu/pool/main/j/jasper/libjasper1_1.900.1-debian1-2.4ubuntu1.2_amd64.deb | |
sudo apt-get install ./libjasper-dev_1.900.1-debian1-2.4ubuntu1.2_amd64.deb ./libjasper1_1.900.1-debian1-2.4ubuntu1.2_amd64.deb | |
#pcl dependencies | |
## read text line by line | |
while IFS= read -r line; do | |
echo "Text read from file: $line" | |
done < "$1" | |
#opencv dependencies | |
sudo apt-get install libeigen3-dev libflann-dev libpcap-dev libusb-1.0-0-dev freeglut3-dev libboost-all-dev libopenni0 libopenni-dev libopenni2-dev libqt4-dev cmake cmake-curses-gui python-pip ipython libmatio-dev libblas-dev build-essential libgtk2.0-dev libjpeg-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtiff-dev | |
sudo pip install cython numpy setuptools sklearn matplotlib h5py path.py theano lasagne | |
sudo cp /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so /usr/local/lib | |
sudo cp /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/local/lib | |
###################### opencv | |
sudo add-apt-repository ppa:xqms/opencv-nonfree | |
`pkg-config --cflags --libs opencv` | |
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D BUILD_SAMPLES=ON .. | |
# with openvino | |
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D BUILD_SAMPLES=ON -DWITH_INF_ENGINE=ON -DENABLE_CXX11=ON .. | |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.0/modules -DOPENCV_ENABLE_NONFREE=True WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=OFF -D WITH_OPENGL=ON -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF .. | |
#disable apps using ccmake ../ | |
##################### wine2.0 | |
sudo add-apt-repository ppa:ricotz/unstable | |
######### ROS | |
source /opt/ros/lunar/setup.bash | |
source ~/catkin_ws/devel/setup.bash | |
#################### PCL viewer | |
pcl_viewer -bc 1,1,1 | |
######33 inquire about .so so library files | |
ldd | |
readelf -Ws | |
#################### CONVERT FLAC TO MP3 | |
for a in *.flac; | |
do | |
ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"; | |
done | |
################## convert jpgs to video | |
cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out.mp4 | |
##### make cmake install | |
export DESTDIR="$HOME/Software/LocalInstall" && make -j4 install | |
################### change desktop background | |
gsettings set org.gnome.desktop.background picture-uri 'file:///home/omair/Pictures/Wallpapers/rf_wimbledon.jpg' | |
########## merge videos into one | |
mkvmerge -o outfile.mkv infile_01.mp4 \+ infile_02.mp4 \+ infile_03.mp4 | |
###############3#@ subversion svn | |
https://github.com/opencv/opencv_attic/tree/master/opencv/samples/android/tutorial-4-mixed | |
svn checkout https://github.com/opencv/opencv_attic/trunk/opencv/samples/android/tutorial-4-mixed | |
sudo add-apt-repository ppa:varlesh-l/indicator-kdeconnect | |
#ROS Stuff | |
rosservice call /spawn #spawn 2nd turtle in turtlesim | |
rostopic pub /turtle1/cmd_vel | |
rosrun turtle_sim turtle_teleop_key cmd_vel:=/turtle1/cmd_vel | |
teleop_key __name:=node3 | |
rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:/hello/cmd_vel | |
rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=115200 | |
sudo rfcomm connect 1 98:D3:31:FD:28:06 | |
#NO PUB KEY | |
wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | sudo apt-key add - | |
#audio | |
sudo apt-add-repository ppa:osmoma/audio-recorder | |
sudo apt-get update && sudo apt-get install audio-recorder | |
######################3 openCL in ubuntu | |
sudo apt install ocl-icd-opencl-dev | |
###################### mate desktop | |
sudo add-apt-repository ppa:jonathonf/mate-1.18 | |
sudo apt-get install --install-suggests mate-desktop | |
##################### autoreconf | |
apt-get install dh-autoreconf | |
#mount over ssh | |
sshfs [email protected]:/windows/D/MapsData/ /home/cvlab/Desktop/maps | |
#gdb commandline parameteres | |
gdb --args executablename arg1 arg2 arg3 | |
#save logs | |
./exe 2>&1 | tee -a log.txt | |
##### video from photos | |
cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out.mp4 | |
###### timelapse from photos | |
ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v mjpeg -q:v 2 output.avi # -q:v can get a value between 2-31. 2 is best quality and bigger size, 31 is worst quality and least size) | |
###### slow down video | |
ffmpeg -i TheGoodTheBadAndTheUgly.mp4 -strict -2 -vf "setpts=4*PTS" DownTheGoodTheBadAndTheUgly.mp4 | |
###### speed up video | |
ffmpeg -i TheGoodTheBadAndTheUgly.mp4 -strict -2 -vf "setpts=0.25*PTS" DownTheGoodTheBadAndTheUgly.mp4 | |
####### convert mkv to mp4 | |
ffmpeg -i input.mkv -codec copy output.mp4 | |
## convert pdf to low res | |
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -sOutputFile=output.pdf input.pdf | |
-dPDFSETTINGS=/screen, /ebook, /prepress, /printer /default | |
convert -density 200x200 -quality 60 -compress jpeg input.pdf output.pdf | |
#convert pdf to grayscale | |
gs \ | |
-sOutputFile=output.pdf \ | |
-sDEVICE=pdfwrite \ | |
-sColorConversionStrategy=Gray \ | |
-dProcessColorModel=/DeviceGray \ | |
-dCompatibilityLevel=1.4 \ | |
-dNOPAUSE \ | |
-dBATCH \ | |
## rotate pdf | |
pdftk in.pdf cat 1east output out.pdf # new pdftk | |
#uninstall vmware player | |
sudo vmware-installer -u vmware-player | |
#list empty directories | |
find . -type d -empty | |
#tensorflow keras | |
tensorflow version 1.4.0 and keras version 2.0.8. | |
tensorboard version 1.8.0 | |
##booting andriod x86 in vmware | |
You have to edit menu.lst file. Here is how: | |
boot in debug mode (usually the second option in boot menu) | |
when booting stops (for me it just hangs there with flashing cursor and without any prompt) enter mount -o remount,rw /mnt | |
enter cd /mnt/grub | |
enter vi menu.lst | |
press Shift+a | |
right under the first boot entry find the line starting with kernel initrd=/in (your line might look different; it depends on Android version; in general just find the line that starts with kernel) | |
at the end of the line type vga=834 nomodeset xforcevesa | |
press ESC then :wq - these commands will save the file and quit vi | |
enter cd / | |
enter umount /mnt | |
enter reboot -f | |
Now the system should reboot in the VESA mode of your choice. | |
This will enforces to use the VESA driver for X. | |
You can replace the vga=xxx by any number you want for your screen resolution. Also tested that 832 works fine (gives 800x600 resolution). | |
############ .so files, shared library ##### | |
readelf -Ws /usr/lib/libexample.so | |
systemctl start vncserver-x11-serviced.service | |
#DOCKER docker | |
#remove all docker images with none tag | |
docker rmi $(docker images | grep "^<none>" | awk "{print $3}") | |
#build docker images | |
docker build -t numpy-docker . | |
#run docker | |
docker run -it numpy-docker | |
sudo chmod 777 /var/run/docker.sock | |
docker run -it numpy-docker /bin/sh -e -c py.test | |
pulseaudio --kill | |
pulseaudio --start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment