Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Saturday, October 1, 2022

Splitting video using linux command line

To easily split (or cut some part) of video using command line, a tool called ffmpeg can be used.


Why use command line? Lighter on resource. Video editing is a high resource activity, and by using command line, we can reduce the resource used on our machine while doing video splitting, especially if we are using low resources machine. 

To install ffmpeg, on an debian based machine, just run below command
$ sudo apt -y install ffmpeg

To do the splitting, just use below command
$ ffmpeg -i mymovie.mp4 -ss 00:01:00 -t 00:00:30 myeditedmovie.mp4

where
-i is for which video to edit
-ss is for where in the video that you want to start
-t is for the duration of the output video

So in the above example, you will get an output called myeditedmovie.mp4, which start from the first minute of the original video, and will last 30 seconds.

Monday, October 18, 2021

Connect to a wifi by scanning a QR code in Linux

There is a project in github, that contain a script to easily accomplish this task. The project is called wifi-qr by kokoye2007. It can be cloned here.


To use the script, we need to clone the project from github.

$ git clone https://github.com/kokoye2007/wifi-qr

Once cloned, go into the project directory.

$ cd wifi-qr

To scan a QR code, and connect to the wifi information contained in the code 

$ ./wifi-qr s

A camera interface will be displayed. Show our wifi QR code to the computer's webcam, and the script will read the QR code and automatically connect to the wifi using the information in the QR code.


Apart from scanning QR code and connecting to the wifi, this script has a lot more functions. You can read about all the functions here. Thank you to kokoye2007 for this excellent tool.

 

Friday, January 22, 2021

Installing Openssl Application to Use SSL Functions

The openssl program is a command line tool for using the various cryptography functions of OpenSSL's crypto library from the shell. 


To install openssl in ubuntu or debian:

$ sudo apt install openssl -y


To install openssl in RHEL, CentOS or Fedora:

$ sudo yum install openssl -y


Tuesday, July 1, 2014

How to install custom upstart script

To install custom upstart script, please follow below steps (in this example, I'll be using a service call cat):

  1. Copy the script into /etc/init 
  2. To make upstart distinguish the new service, run: 
    • $ initctl reload-configuration 
  3. Check whether your script is already in upstart by running:
    • $ initctl list | grep cat 
      cat stop/waiting
  4. And you are done, you can check the status of your service by running:
    • $ service cat status 
      cat stop/waiting
  5. You can also do the same with start, stop and restart
    • $ service cat start
      * Starting cat .... [OK]
    • $ service cat stop
      * Stopping cat .... [OK]
    • $ service cat restart * Restarting cat .... [OK]

Monday, August 26, 2013

How to extract deb file without having dpkg

.deb files are regular ar archives. You can manipulate the file by using ar command.

For example, I have a package called lynx_2.8.8dev.15-2_all.deb in a centos box.

$ cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m

$ ls -lh
total 4.0K
-rw-rw-r--. 1 foo foo 3.9K Jan 18  2013 lynx_2.8.8dev.15-2_all.deb

To extract the file, just run ar x <.deb.filename>
$ ar x lynx_2.8.8dev.15-2_all.deb
You will see 3 files being extracted, control.tar.gz, data.tar.gz and debian binary.
$ ls
control.tar.gz  data.tar.gz  debian-binary  lynx_2.8.8dev.15-2_all.deb

debian-binary is a text file containing deb packaging version number.
$ cat debian-binary 
2.0

control.tar.gz contained control, preinst and md5sums.
$ tar -tf control.tar.gz ./
./md5sums
./control
./preinst

data.tar.gz is a compressed file containing the files which are going to be installed on the system.
$ tar -tf data.tar.gz ./
./usr/
./usr/share/
./usr/share/doc/
./usr/share/doc/lynx/
./usr/share/doc/lynx/copyright
./usr/share/doc/lynx/changelog.Debian.gz

Monday, May 25, 2009

Setting ip in debian/ubuntu server

To setup ip for debian or ubuntu server is not easy for someone who is not familiar with command line. For normal ubuntu desktop user, there is always NetworkManager applet to easily set up the network using GUI, which is very easy. There are 2 ways to setup ip for debian or ubuntu server. One will set the ip temporarily and the otehr one will permanently set the ip. I will show both :)

To set ip temporarily using ifconfig and route commands

1. Run the command below to set ip and netmask
$ sudo ifconfig eth0 10.20.1.10 netmask 255.255.255.0 up
where eth0 is the name of the interface, 255.255.255.0 is the netmask and up to activate the interface

2. run route command to set default gateway
$ sudo route add default gw 10.20.1.1
where 10.20.1.1 is your gateway ip

3. You can check the configuration that you have setup using commands route -n to see the gateway and ifconfig to see the ip address

Done.


To permanently set up the ip and gateway, you have to edit /etc/network/interfaces. It is advisable if you backup the existing interfaces file, if it is available.

1. Backup /etc/network/interfaces
$ sudo cp /etc/network/interfaces /etc/network/interfaces.bak

2. Open the /etc/network/interfaces using your favorite text editor
$ sudo vi /etc/network/interfaces

3. Add the below setting to add ip, netmask and gateway

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
#set your static IP below

address 10.20.1.10
#set your default gateway IP here
gateway 10.20.1.1
# set your netmask, network and broadcast ip below
netmask 255.255.255.0
network 10.20.1.0
broadcast 10.20.1.255

4. Save your configuration and restart network
$ sudo /etc/init.d/network restart

5. Your debian/ubuntu server machine is now operating with the new ip. Check ip and gateway using ifconfig and route -n