Important Linux Commands

Linux is an Unix like opensource operating system designed to run on handhelds, phones, tablets, laptops, desktops, servers including mainframes. Linux is developed under the GPL or GNU Public License and was initially released by Linus Torvalds. A Linux operating system is in reality a Unix-like operating systems which runs a “Linux kernel” first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution or distro in short, which includes the kernel and supporting system software and libraries, many of which are provided by the GNU Project.

It is common to call the operating system as Linux, however in reality the operating system is made up of thousands of other programs (many of them developed by the Free Software Foundation) which run on top of the Linux kernel. The Free Software Foundation uses and recommends the name “GNU/Linux” to emphasize the use and importance of GNU software in many distributions. This article is my attempt at capturing the most important linux commands i have needed to use to administer the half a dozen Linux machines i have running around the house. This article will not list all the basics commands folks most often use but rather those commands that are rarely used and hence a bit difficult to remember.

Useful Linux Commands

  • Detecting USB Cameras –
    • Install the required tools : sudo apt-get install v4l-utils
    • List all the installed Video devices : sudo v4l2-ctl –list-devices
  • USB Cameras –
    • Install ffmpeg : sudo apt install ffmpeg
    • Play Video : ffplay /dev/video0
    • Probe Video file : ffprobe out.mkv
    • List supported video modes : v4l2-ctl –list-formats-ext
    • List corresponding ffmpeg encodings : ffmpeg -f v4l2 -list_formats all -i /dev/video0
    • Capture a picture : ffmpeg -f v4l2 -video_size 1280×720 -i /dev/video0 -frames 1 out.jpg
  • Motion configuration for two USB cameras –
    • /etc/motion/motion.conf
      • daemon on
      • setup_mode off
      • log_level 6
      • emulate_motion off
      • picture_output off
      • movie_output off
      • webcontrol_port 8080
      • webcontrol_localhost off
      • webcontrol_parms 0
      • camera /etc/motion/config/camera1.conf
      • camera /etc/motion/config/camera2.conf
    • /etc/motion/camera1.conf
      • camera_name CAM-1
      • camera_id 001
      • videodevice /dev/video0
      • text_left CAM-1
      • stream_port 8081
      • stream_localhost off
      • stream_maxrate = 35
    • /etc/motion/camera2.conf
      • camera_name CAM-2
      • camera_id 002
      • videodevice /dev/video1
      • text_left CAM-2
      • stream_port 8082
      • stream_localhost off
      • stream_maxrate = 35
    • Restart motion : sudo systemctl restart motion
  • Find Files –
    • Find files with a particular file name : find . -name *ones*
    • Find files with name having the letters “ones” in it : find . | grep -i *ones*
  • Audio –
    • Change the default audio device i.e. : amixer cset numid=3 n (Where n is the required interface : 0=auto, 1=analog, 2=hdmi. To force the Raspberry Pi to use the analog output)
    • Play a wave file using aplay : aplay file.wav
    • Install mpg321 : sudo apt-get -y install mpg321
    • Play music with mpg321 : mpg321 -g 50% music.mp3
  • CPU Statistics –
    • Measure Raspberry Pi CPU Temperature : vcgencmd measure_temp
  • TBC

S3 Commands for Linode

  • Delete files recursively : sudo s3cmd rm –recursive –force s3://kidzcancode-datastore
  • Copy files to the Linode file repo : s3cmd put kidzcancode_downloads/ s3://kidzcancode-datastore –acl-public –recursive

As mentioned earlier on this page, the commands listed here are a collection of rarely used but important commands that i used to administer the Raspberry Pi and Ubuntu boxes i have around the house. If you spot any issues please drop me a note at trevor at hack2 dot live.

Leave a Reply

Your email address will not be published. Required fields are marked *