Red Hat Linux Certification Books
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Sunday, 27 December 2020
Thursday, 20 August 2015
Socket
Linux Socket Programming, server will perform arithmetic operations
Code for Client
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
int main(int argc,int *argv[])
{
int n1=atoi(argv[1]),n2=atoi(argv[2]),res=0;
char operator=argv[3][0];
int sock_id=socket(AF_UNIX,SOCK_STREAM,0);
if(sock_id<0)
{
printf("Error in getting socket\n");
return 0;
}
struct sockaddr_in clientstruct;
clientstruct.sin_family=AF_UNIX;
clientstruct.sin_addr.s_addr=inet_addr("127.0.0.1");
clientstruct.sin_port=1025;
int ret=connect(sock_id,(struct sockaddr *)&clientstruct,sizeof(clientstruct));
write(sock_id,&n1,sizeof(n1));
write(sock_id,&n2,sizeof(n2));
write(sock_id,&operator,sizeof(operator));
int ret1=read(sock_id,&res,sizeof(res));
printf("FROM SERVER:%d \n Bytes=%d\n",res,ret1);
close(sock_id);
return 0;
}
Code for Server
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
int main()
{
int n1,n2,res=0;
char operator;
int session_id;
int server_id=socket(AF_UNIX,SOCK_STREAM,0);
if(server_id<0)
{
printf("Error in getting socket\n");
return 0;
}
struct sockaddr_in serverstruct,clientstruct;
serverstruct.sin_family=AF_UNIX;
serverstruct.sin_addr.s_addr=inet_addr("127.0.0.1");
serverstruct.sin_port=1025;
int i=bind(server_id,(struct sockaddr*)&serverstruct,sizeof(serverstruct));
if(i<0)
{
printf("Error in bind\n");
return 0;
}
i=listen(server_id,10);
if(i<0)
{
printf("Error in listening\n");
return 0;
}
int client_len=sizeof(serverstruct);
while(1)
{
printf("Waiting for the client\n");
session_id=accept(server_id,(struct sockaddr*)&serverstruct,&client_len);
read(session_id,&n1,sizeof(n1));
read(session_id,&n2,sizeof(n2));
read(session_id,&operator,sizeof(operator));
switch(operator)
{
case '+':
res=n1+n2;
break;
case '-':
res=n1-n2;
break;
case '*':
res=n1*n2;
break;
case '/':
res=n1/n2;
break;
default:
printf("invalid operation\n");
}
printf("From CLIENT:n1=%d\n",n1);
printf("From CLIENT:n2=%d\n",n2);
printf("From CLIENT:operator=%c\n",operator);
int b=write(session_id,&res,sizeof(res));
close(session_id);
}
close(server_id);
return 0;
}
Wednesday, 15 July 2015
LINUX NETWORKING COMMANDS
Linux is most powerful operating system which often needs to use commands to explore it effectively.Some of the commands are restricted to normal user groups as they are powerful and has more functionality involved in it.Here we summarized most interesting and useful networking commands which every linux user are supposed to be familiar with it.
1.Arp manipulates the kernel’s ARP cache in various ways. The primary options are clearing an address mapping entry and manually setting up one. For debugging purposes, the arp program also allows a complete dump of the ARP cache.ARP displays the IP address assigned to particular ETH card and mac address
2.Ifconfig is used to configure the network interfaces. Normally we use this command to check the IP address assigned to the system.It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
[fasil@smashtech ~]# /sbin/ifconfig
eth0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:126341 errors:0 dropped:0 overruns:0 frame:0
TX packets:44441 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
3. Netstat prints information about the networking subsystem. The type of information which is usually printed by netstat are Print network connections, routing tables, interface statistics, masquerade connections, and multicast.
[fasil@smashtech ~]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 .230.87:https ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 10 [ ] DGRAM 4970 /dev/log
unix 2 [ ] DGRAM 6625 @/var/run/hal/hotplug_socket
unix 2 [ ] DGRAM 2952 @udevd
unix 2 [ ] DGRAM 100564
unix 3 [ ] STREAM CONNECTED 62438 /tmp/.X11-unix/X0
unix 3 [ ] STREAM CONNECTED 62437
unix 3 [ ] STREAM CONNECTED 10271 @/tmp/fam-root-
unix 3 [ ] STREAM CONNECTED 10270
unix 3 [ ] STREAM CONNECTED 9276
unix 3 [ ] STREAM CONNECTED 9275
4.ping command is used to check the connectivity of a system to a network.Whenever there is problem in network connectivity we use ping to ensure the system is connected to network.
[root@smashtech ~]# ping google.com
PING google.com (74.125.45.100) 56(84) bytes of data.
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=0 ttl=241 time=295 ms
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=1 ttl=241 time=277 ms
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=2 ttl=241 time=277 ms
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6332ms
rtt min/avg/max/mdev = 277.041/283.387/295.903/8.860 ms, pipe 2
5.Nslookup is a program to query Internet domain name servers. Nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.
[fasil@smashtech ~]# nslookup google.com
Server: server ip
Address: gateway ip 3
Non-authoritative answer:
Name: google.com
Address: 209.85.171.100
Name: google.com
Address: 74.125.45.100
Name: google.com
Address: 74.125.67.100
6. dig (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.
[fasil@smashtech ~]# dig google.com
; <<>> DiG 9.2.4 <<>> google.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4716
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 122 IN A 74.125.45.100
google.com. 122 IN A 74.125.67.100
google.com. 122 IN A 209.85.171.100
;; AUTHORITY SECTION:
google.com. 326567 IN NS ns3.google.com.
google.com. 326567 IN NS ns4.google.com.
google.com. 326567 IN NS ns1.google.com.
google.com. 326567 IN NS ns2.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 152216 IN A 216.239.32.10
ns2.google.com. 152216 IN A 216.239.34.10
ns3.google.com. 152216 IN A 216.239.36.10
ns4.google.com. 152216 IN A 216.239.38.10
;; Query time: 92 msec
;; SERVER: 172.29.36.1#53(172.29.36.1)
;; WHEN: Thu Mar 5 14:38:45 2009
;; MSG SIZE rcvd: 212
7.Route manipulates the IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig program.When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
[fasil@smashtech ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
54.192.56.321 * 255.255.255.0 U 0 0 0 eth0
* 255.255.0.0 U 0 0 0 eth0
default 0.0.0.0 UG 0 0 0 eth0
8.Traceroute : Internet is a large and complex aggregation of network hardware, connected together by gateways. Tracking the route one’s packets follow (or finding the miscreant gateway that’s discarding your packets) can be difficult.
Traceroute utilizes the IP protocol ‘time to live’ field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host. The only mandatory parameter is the destination host name or IP number. The default probe datagram length is 40 bytes, but this may be increased by specifying a packet length (in bytes) after the destination host name.
[fasil@smashtech ~]# traceroute google.com
traceroute: Warning: google.com has multiple addresses; using 209.85.171.100
traceroute to google.com (209.85.171.100), 30 hops max, 38 byte packets
1 * * *
9.W-displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
[fasil@smashtechl ~]# w
15:18:22 up 4:38, 3 users, load average: 0.89, 0.34, 0.19
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 - 10:41 ?xdm? 24:53 1.35s /usr/bin/gnome-session
root pts/1 :0.0 10:58 1.00s 0.34s 0.00s w
root pts/2 :0.0 12:10 23:32 0.03s 0.03s bash
10. Nmap is designed to allow system administrators and curious individuals to scan large networks to determine which hosts are up and what services they are offering. nmap supports a large number of scanning techniques such as:UDP, TCP connect(), TCP SYN (half open), ftp proxy (bounce attack), ICMP (ping sweep), FIN, ACK sweep, Xmas Tree,SYN sweep, IP Protocol, and Null scan. See the Scan Types section for more details. nmap also offers a number of advanced features such as remote OS detection via TCP/IP fingerprinting, stealth scanning, dynamic delay and retransmission calculations, parallel scanning, detection of down hosts via parallel pings, decoy scanning, port filtering detection, direct (non-portmapper) RPC scanning, fragmentation scanning, and flexible target and port specification.
Significant effort has been put into decent nmap performance for non-root users. Unfortunately, many critical kernel interfaces (such as raw sockets) require root privileges. nmap should be run as root whenever possible (not setuid root, of course).
The result of running nmap is usually a list of interesting ports on the machine(s) being scanned (if any). Nmap always gives the port’s "well known" service name (if any), number, state, and protocol. The state is either"open", "filtered", or "unfiltered". Open means that the target machine will accept() connections on that port.Filtered means that a firewall, filter, or other network obstacle is covering the port and preventing nmap from determining whether the port is open. Unfiltered means that the port is known by nmap to be closed and no fire-wall/filter seems to be interfering with nmap’s attempts to determine this. Unfiltered ports are the common case and are only shown when most of the scanned ports are in the filtered state.
Depending on options used, nmap may also report the following characteristics of the remote host: OS in use, TCP sequentiality, usernames running the programs which have bound to each port, the DNS name, whether the host is a smurf address, and a few other--Network exploration tool and security scanners.
[fasil@smashtech ~]# nmap 52.194.69.152
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2009-03-05 15:21 IST
Interesting ports on 52.194.69.152
(The 1658 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
Linux is most powerful operating system which often needs to use commands to explore it effectively.Some of the commands are restricted to normal user groups as they are powerful and has more functionality involved in it.Here we summarized most interesting and useful networking commands which every linux user are supposed to be familiar with it.
1.Arp manipulates the kernel’s ARP cache in various ways. The primary options are clearing an address mapping entry and manually setting up one. For debugging purposes, the arp program also allows a complete dump of the ARP cache.ARP displays the IP address assigned to particular ETH card and mac address
[fasil@smashtech ]# arp Address HWtype HWaddress Flags Mask Iface 59.36.13.1 ether C eth0 |
2.Ifconfig is used to configure the network interfaces. Normally we use this command to check the IP address assigned to the system.It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
[fasil@smashtech ~]# /sbin/ifconfig
eth0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:126341 errors:0 dropped:0 overruns:0 frame:0
TX packets:44441 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
3. Netstat prints information about the networking subsystem. The type of information which is usually printed by netstat are Print network connections, routing tables, interface statistics, masquerade connections, and multicast.
[fasil@smashtech ~]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 .230.87:https ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 10 [ ] DGRAM 4970 /dev/log
unix 2 [ ] DGRAM 6625 @/var/run/hal/hotplug_socket
unix 2 [ ] DGRAM 2952 @udevd
unix 2 [ ] DGRAM 100564
unix 3 [ ] STREAM CONNECTED 62438 /tmp/.X11-unix/X0
unix 3 [ ] STREAM CONNECTED 62437
unix 3 [ ] STREAM CONNECTED 10271 @/tmp/fam-root-
unix 3 [ ] STREAM CONNECTED 10270
unix 3 [ ] STREAM CONNECTED 9276
unix 3 [ ] STREAM CONNECTED 9275
4.ping command is used to check the connectivity of a system to a network.Whenever there is problem in network connectivity we use ping to ensure the system is connected to network.
[root@smashtech ~]# ping google.com
PING google.com (74.125.45.100) 56(84) bytes of data.
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=0 ttl=241 time=295 ms
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=1 ttl=241 time=277 ms
64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=2 ttl=241 time=277 ms
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6332ms
rtt min/avg/max/mdev = 277.041/283.387/295.903/8.860 ms, pipe 2
5.Nslookup is a program to query Internet domain name servers. Nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.
[fasil@smashtech ~]# nslookup google.com
Server: server ip
Address: gateway ip 3
Non-authoritative answer:
Name: google.com
Address: 209.85.171.100
Name: google.com
Address: 74.125.45.100
Name: google.com
Address: 74.125.67.100
6. dig (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.
[fasil@smashtech ~]# dig google.com
; <<>> DiG 9.2.4 <<>> google.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4716
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 122 IN A 74.125.45.100
google.com. 122 IN A 74.125.67.100
google.com. 122 IN A 209.85.171.100
;; AUTHORITY SECTION:
google.com. 326567 IN NS ns3.google.com.
google.com. 326567 IN NS ns4.google.com.
google.com. 326567 IN NS ns1.google.com.
google.com. 326567 IN NS ns2.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 152216 IN A 216.239.32.10
ns2.google.com. 152216 IN A 216.239.34.10
ns3.google.com. 152216 IN A 216.239.36.10
ns4.google.com. 152216 IN A 216.239.38.10
;; Query time: 92 msec
;; SERVER: 172.29.36.1#53(172.29.36.1)
;; WHEN: Thu Mar 5 14:38:45 2009
;; MSG SIZE rcvd: 212
7.Route manipulates the IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig program.When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
[fasil@smashtech ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
54.192.56.321 * 255.255.255.0 U 0 0 0 eth0
* 255.255.0.0 U 0 0 0 eth0
default 0.0.0.0 UG 0 0 0 eth0
8.Traceroute : Internet is a large and complex aggregation of network hardware, connected together by gateways. Tracking the route one’s packets follow (or finding the miscreant gateway that’s discarding your packets) can be difficult.
Traceroute utilizes the IP protocol ‘time to live’ field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host. The only mandatory parameter is the destination host name or IP number. The default probe datagram length is 40 bytes, but this may be increased by specifying a packet length (in bytes) after the destination host name.
[fasil@smashtech ~]# traceroute google.com
traceroute: Warning: google.com has multiple addresses; using 209.85.171.100
traceroute to google.com (209.85.171.100), 30 hops max, 38 byte packets
1 * * *
9.W-displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
[fasil@smashtechl ~]# w
15:18:22 up 4:38, 3 users, load average: 0.89, 0.34, 0.19
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 - 10:41 ?xdm? 24:53 1.35s /usr/bin/gnome-session
root pts/1 :0.0 10:58 1.00s 0.34s 0.00s w
root pts/2 :0.0 12:10 23:32 0.03s 0.03s bash
10. Nmap is designed to allow system administrators and curious individuals to scan large networks to determine which hosts are up and what services they are offering. nmap supports a large number of scanning techniques such as:UDP, TCP connect(), TCP SYN (half open), ftp proxy (bounce attack), ICMP (ping sweep), FIN, ACK sweep, Xmas Tree,SYN sweep, IP Protocol, and Null scan. See the Scan Types section for more details. nmap also offers a number of advanced features such as remote OS detection via TCP/IP fingerprinting, stealth scanning, dynamic delay and retransmission calculations, parallel scanning, detection of down hosts via parallel pings, decoy scanning, port filtering detection, direct (non-portmapper) RPC scanning, fragmentation scanning, and flexible target and port specification.
Significant effort has been put into decent nmap performance for non-root users. Unfortunately, many critical kernel interfaces (such as raw sockets) require root privileges. nmap should be run as root whenever possible (not setuid root, of course).
The result of running nmap is usually a list of interesting ports on the machine(s) being scanned (if any). Nmap always gives the port’s "well known" service name (if any), number, state, and protocol. The state is either"open", "filtered", or "unfiltered". Open means that the target machine will accept() connections on that port.Filtered means that a firewall, filter, or other network obstacle is covering the port and preventing nmap from determining whether the port is open. Unfiltered means that the port is known by nmap to be closed and no fire-wall/filter seems to be interfering with nmap’s attempts to determine this. Unfiltered ports are the common case and are only shown when most of the scanned ports are in the filtered state.
Depending on options used, nmap may also report the following characteristics of the remote host: OS in use, TCP sequentiality, usernames running the programs which have bound to each port, the DNS name, whether the host is a smurf address, and a few other--Network exploration tool and security scanners.
[fasil@smashtech ~]# nmap 52.194.69.152
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2009-03-05 15:21 IST
Interesting ports on 52.194.69.152
(The 1658 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
LINUX
File Handling Linux Commands
Linux has become most prominent operating system and for effective use of Linux system we should know certain basic file handling commands to perform our day-to-day operations in most efficient way. Here we have listed some of the most important and interesting File Handling commands which are ordered in categories wise to improve your Linux skills.
Easy File Viewing and Editing
We use gedit tool in Linux which is similar to notepad or WordPad in windows and it also got tabbed viewing of text files. But at the same time we should get familiar with using commands and this most will make that easier. Basic Text editors in Linux are Vim and Emacs which supports syntax highlighting and helps you a lot in programming skills. Some of the commands features are discussed here
Vim is easy to use and powerful text edit intended for beginner and advanced users. It has lot of in featured commands for text editing for simple task like copy, paste and some advanced commands like searching text, find and replace option.
[fasil@smashtech ~]# vim smashtech.txt |
The above command will open the text file in the Vim editor and you can easily edit the text file and save it by entering the Escape key -> :w and to quit the editor Escape key -> :q .To know more about Vim commands download this cheat sheets.
Emacs is most powerful editor intended for advanced users. Prominent use of emacs is multiple window use. We can easily open almost four to five windows with horizontal or vertical view and helps you alot in manipulating multiple files.
[fasil@smashtech ~]# emacs smashtech.txt |
The above command will open the text file in the Emacs editor and once editing is completed. Press ctrl+x+s to save file and to quit editor ctrl+x+c.To know more about emacs commands download this cheat sheet.
cat command will list the content of the file in the terminal .This option is limited to view files having only few lines since you have to scroll back to view the text if it is a large file.
[fasil@smashtech ~]# cat smashtech.txt This text is displayed using cat command |
Simple command to view text files and to list the files in compressed archive like tar or zip.
[fasil@smashtech ~]#less smashtech.tar.gz -rw-rw-r-- root/root 326 2009-03-04 13:48:50 /Documentation/RelNotes-1.5.3.1.txt -rw-rw-r-- root/root 1931 2009-03-04 13:48:50 Documentation/RelNotes-1.5.3.2.txt -rw-rw-r-- root/root 896 2009-03-04 13:48:50 /Documentation/RelNotes-1.5.3.3.txt -rw-rw-r-- root/root 1208 2009-03-04 13:48:50 /Documentation/RelNotes-1.5.3.4.txt -rw-rw-r-- root/root 3376 2009-03-04 13:48:50 |
Checking file size and disk usage
Simple commands like 'list' can be used to check the file size or folder size but the Linux has some more powerful commands to do so.
df - report filesystem disk space usage is simple command to check the disk space in all partitions of harddisk.
[Fasil@smashtech ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda6 19.7G 18.1G 1.1G 89% / |
du - estimate file space usage of all files and folders
[Fasil@smashtech ~]# du -sh . 602M . |
Simply Copy/rename and move files
Copying, moving and deleting files like never before, Simply saying you can delete files and folders very fast in command prompt then using mouse in GUI.But here is a caution although Linux is more powerful it does not have an undo command and if you delete a file/folder my mistake its loss. There are some methods to recover it but redundancy will be lost. cp - Copy files from source location to destination
[Fasil@smashtech ~]# cp file1.txt file2.txt The above command will copy file1 as file2 text file [Fasil@smashtech ~]# cp -a smashtech fasil the above command will copy the folder smashtechtech as fasil |
mv-Move a file from original location to final location
[Fasil@smashtech ~]# mv file1.txt file2.txt The above command will move/rename file1 as file2 text file [Fasil@smashtech ~]#mv -a smashtech fasil the above command will move contents of the folder smashtech to fasil |
rm-Remove a file or folder
[Fasil@smashtech ~]# rm file1.txt The above command will delete file1 [Fasil@smashtech ~]#rm -rf smashtech the above command will delete the folder smashtech |
Compressing and Decompressing Files and Folders
The most interesting usage in Linux commands are compressing the text files in more efficient and effective way and some of the compressing and decompressing commands are shown here.
tar- This command is used for both compressing and extracting
[Fasil@smashtech ~]# tar -cvf filename.tar folder/ The above command will create a tar archive with name.tar and folder is archived Fasil@smashtech ~]# tar -cvzf filename.tar.gz folder/ The above command will create a gzip archive with name.tar and folder is archived Fasil@smashtech ~]# tar -cvjf filename.tar.bz2 folder/ The above command will create a bzip2 archive with name.tar and folder is archived |
[Fasil@smashtech ~]# tar -xvf filename.tar The above command will extract the content of the tar archive with name.tar Fasil@smashtech ~]# tar -cvzf filename.tar.gz folder/ The above command will extract the content of a gzip archive Fasil@smashtech ~]# tar -cvjf filename.tar.bz2 folder/ The above command will extract the content of the bzip2 archive |
Tuesday, 12 May 2015
MASM
How to run MASM Assembler 8086 in Ubuntu or Windows 7 with the help of DOSBox
Here’s how to run 16 bit DOS executables like the MASM assembler or Turbo C compiler in Ubuntu (GNU/Linux) or in 64 bit editions of Windows 7 using DOSBox, a DOS environment emulator. DOSBox is available for Linux as well as Windows.
DOSBox installation
For Ubuntu users (using repository)
Open the terminal and type in the following commands to download and install DOSbox in Ubuntu
You will find it installed under Applications_Menu->Games->DOSBox Emulator
Open the terminal and type in the following commands to download and install DOSbox in Ubuntu
sudo apt-get update
sudo apt-get install dosbox
You will find it installed under Applications_Menu->Games->DOSBox Emulator
For other GNU/Linux users
Download DOSbox from here.
Open terminal and cd to the directory containing the downloaded tar.gz file. Type in the following commands to build and install :
Check the src subdir for the binary.
Download DOSbox from here.
Open terminal and cd to the directory containing the downloaded tar.gz file. Type in the following commands to build and install :
tar -xzvf dosbox-0.74.tar.gz
cd dosbox-0.74
./configure
make
Check the src subdir for the binary.
For Windows users
Download DOSbox from here.
Run the downloaded .exe file and install it like any other software.
Download DOSbox from here.
Run the downloaded .exe file and install it like any other software.
Now that you’ve installed DOSBox, you’ll be able to run any 16bit or 32bit DOS executable inside it.
Download the 8086 MASM Assembler from here. The zip file contains the following files :
masm.exe, tasm.exe, link.exe, bin2hex.exe, exe2bin.exe, td.exe, edit.com and debug.exe
Windows users extract the .zip file into C:\ so that the path C:\8086 contains all the above mentioned files. GNU/Linux users can extract it and place it in say /home/prashanth/8086
Launch DOSBox and type the following commands :
For Linux users :
For Windows :
For Linux users :
mount c /home/prashanth/8086
c:
For Windows :
mount c c:\8086
c:
Now the contents of the folder /home/prashanth/8086 or c:\8086 is mounted as c: drive inside the DOS emulator. You can assemble programs inside DOSBox as you do in your Microprocessor Lab under Windows XP; i.e your usual sequence of commands -
edit file.asm
masm file.asm
link file
debug file.exe
When you are done, type exit to quit DOSBox.
P.S : For GNU/Linux users, there’s an alternative assembler known as the NASM. NASM is considered to be one of the most popular assemblers for GNU/Linux.
Click below to Download
DOSBox for Linux : dosbox-0.74.tar.gz
DOSBox for Windows : DOSBox0.74-win32-installer.exe
8086 Assembler : 8086_Assembler.zip
Friday, 21 November 2014
Downloading Youtube video based on Command in Fedora Linux
Here is a tool that is available in the command line (Terminal based) on Linux Operating Systems.
That is youtube-dl, this is a python based code and can be executed in linux OS without any hassles.
youtube-dl in windows or Mac OS can be achieved by installing python interpreter and try it.
for installing in linux, the command is
$prompt] sudo yum install youtube-dl (in redhat or centos or fedora)
$prompt] sudo apt-get install youtube-dl (ubuntu or linux mint)
For Ubuntu users, you can update the sudo package before installing the youtube-dl.
sudo apt-get update
To download videos
$prompt] youtube-dl https://www.youtube.com/watch?v=cYg5VCV3zeU
The above is output and to download the corresponding video format, then here is the command
$prompt] youtube-dl -f 18 To view all formats, use the following command,
$prompt] youtube-dl -F http://www.youtube.com/watch?v=cYg5VCV3zeU
[youtube] Setting language
[youtube] cYg5VCV3zeU: Downloading webpage
[youtube]cYg5VCV3zeU: Downloading video info webpage
[youtube] cYg5VCV3zeU: Extracting video information
[info] Available formats for cYg5VCV3zeU:
format code extension resolution note
139 m4a audio only DASH audio , audio@ 48k (worst)
140 m4a audio only DASH audio , audio@128k
160 mp4 192p DASH video
133 mp4 240p DASH video
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
18 mp4 640x360
43 webm 640x360 (best)
The above is output and to download the corresponding video format, then here is the command
$prompt] youtube-dl -f 18 http://www.youtube.com/watch?v=cYg5VCV3zeU
The above command will download the file in the mp4 format as specified in the option obtained in the previous command.
if you need any help on the commands, you can use the following command
$prompt] youtube-dl --help
Often, youtube-dl is updated, it can be easily updated as given below,
$prompt] sudo youtube-dl -U
Also now youtube-dl supports various other video streaming sites also, to name a few, vimeo.com, dailymotion.com, etc.
If you are behind the proxy, type the command in the terminal use this
export http_proxy=172.16.1.1:8080/
or else copy the above line in /etc/profile.d/proxy.sh (this will be set for all the users of the computer, also need root password)
The above command will download the file in the mp4 format as specified in the option obtained in the previous command.
if you need any help on the commands, you can use the following command
$prompt] youtube-dl --help
Often, youtube-dl is updated, it can be easily updated as given below,
$prompt] sudo youtube-dl -U
Also now youtube-dl supports various other video streaming sites also, to name a few, vimeo.com, dailymotion.com, etc.
If you are behind the proxy, type the command in the terminal
export http_proxy=172.16.1.1:8080/
or copy the above line in /etc/profile.d/proxy.sh (this will be set for all the users of the computer, also need root password)
Sunday, 2 November 2014
SUMO Simulation of Urban Mobility installation in Linux (Debian/Ubuntu/Mint)
SUMO-Simulation of Urban Mobility
SUMO an open source, microscopic, multi-modal traffic simulation.
It allows to simulate how a given traffic demand which consists of single vehicles moves through a given road network. The simulation allows to address a large set of traffic management topics. It is purely microscopic: each vehicle is modelled explicitly, has an own route, and moves individually through the network.
SUMO INSTALLATION PROCEDURE:
Step 1: Download the SUMO latest source-tarball from here. At the time of this writing, it was version sumo-src-0.21.0.tar.gz.
Step 2: Change into the directory in which you downloaded the tarball file. In my case, it's the Downloads directory, inside my home:$ cd
$ cd Downloads
Step 3: Two Prerequisites packages are necessary to build SUMO with GUI: type
$ sudo apt-get install libgdal1-dev proj libxerces-c2-dev
$ sudo apt-get install libfox-1.6-dev libgl1-mesa-dev libglu1-mesa-dev
Step 4: Ubuntu 12.04 does not ship with libgdal.so, only with libgdal1.7.0.so. So, create a symbolic link:
$ sudo ln -s /usr/lib/libgdal1.7.0.so /usr/lib/libgdal.
Note: Ubuntu 14.04 doesnt require this step. It comes inbuilt with libgdal package.
Step 5: Installation:
Decompress the tarball:
$ tar -xzvf sumo-src-0.15.0.tar.gz
Step 6: Move the decompressed directory to '/usr/local/src':
$ sudo mv -v sumo-0.15.0 /usr/local/src
Step 7: Enter the source directory and call configure, make and make install:
$ cd /usr/local/src/sumo-0.15.0
$ ./configure --with-fox-includes=/usr/include/fox-1.6 \
--with-gdal-includes=/usr/include/gdal --with-proj-libraries=/usr \
--with-gdal-libraries=/usr --with-proj-gdal
Step 8: type
$ make
$ sudo make install
Step 9: To call SUMO in the command line, type:
$ sumo-gui
For more details about SUMO, go to their homesite.http://sumo-sim.org/userdoc/Sumo_at_a_Glance.html
Mail me for any installation issues.
How to Patch i.e., Inclusion of new files into patch and creation of patch on linux
Programmer who take part in some kind of big code needs to generate
patch files. Begginers do get trouble here as how to create, there is
simpple command on linux diff use that as follows
Suppose u have old code in oldmake folder and new code in home/newmake.
Suppose u have old code in oldmake folder and new code in home/newmake.
Then follow these steps.
1. cd home
2. diff -urN /home/waste/oldmake newmake > patch1
Now
you might have written some new file instead of modifying any file.
There is no need to worry diff is already taken care of that stuff, your
patch includes those files.
How to use patch
if you want to apply patch inside /home/checkmake then go to checkmake folder
How to use patch
if you want to apply patch inside /home/checkmake then go to checkmake folder
1. cd /home/checkmake
2. patch -p patch1
Remote desktop on fedora from fedora client
On client fedora machine:
"yum install tsclient"
you may require sudo permission to run above command.
On fedora server:
"yum install vnc-server"
this will install vnc server on your fedora machine. then set the password for your vnc server using below command
"vncpasswd"
this will prompt for a password. Enter the password which you want to use later when you trying to connect from fedora client. Now time to start your vnc server
"service vncserver start"
Now if you try to connect from client to this server using command
"vncviewer serverip"
it may give you "unable connect to socket: Connection refused (111)"
then use sudo permission on server to stop firewalls using
"service iptables stop"
now you all set to remote the server.
Note:- it may still shows "unable connect to socket: Connection refused (111)" in that case cancel your server at the current port and start the server with next port and try vncviewer serverip :port
Wednesday, 18 September 2013
Linux
Important Tools and Downloads
RED FLAG LINUX
Click here to download the printflush.Zip file,extract the file and update Run Printflush.bat with administrative privileges.
now anytime print job is stuck double click the batch file and here you go.
I used the Disk Cleanup Tool in Windows Vista, and now the hybrid sleep feature and the hibernation feature are unavailable
http://go.microsoft.com/?linkid=9645383
Download and run the above file to resolve the issue.
Microsoft Downloads:
UPS Application Update
- Download ISO file (Version 6.0 Desktop SP1)
Click here to download the printflush.Zip file,extract the file and update Run Printflush.bat with administrative privileges.
now anytime print job is stuck double click the batch file and here you go.
I used the Disk Cleanup Tool in Windows Vista, and now the hybrid sleep feature and the hibernation feature are unavailable
http://go.microsoft.com/?linkid=9645383
Download and run the above file to resolve the issue.
Microsoft Downloads:
UPS Application Update
- USB Power Surge Error
- Windows Vista asking for activation on a pre-installed Desktop
- Windows installer cleanup utility
- Windows Vista HOTFIX
- DirectX 9c for windows XP
- “Generic Host process Error” For Windows XP
- Windows Defender
- Microsoft Universal Audio Architecture drivers (UAA now same can be requested from Microsoft)
- Decoder Checkup utility
- Microsoft .Net framework 1.1
- Microsoft .Net framework 2.0
- Microsoft .Net framework 3.5
- Microsoft® Windows® Malicious Software Removal Tool (KB890830)
- Windows Installer 3.1 Redistributable (v2)
- Windows Installer 4.5 Redistributable
- Windows XP service pack 3 Standalone installer KB936929
- Windows Vista Service Pack 1 (Information and Download)
- Windows Vista Service Pack 2 (Requires Vista SP1 given above)
- Search for an error message on Support.Microsoft.com
- Windows messenger 5.1
- Windows 7 Download and Product Key
- Microsoft Office Trail Activation key
Anti Virus Utilities:
- Enable registry, folder options
- Disable Write protection on USB (New)
- Mal Ware removal for vista Update error
- Generic Host process error in windows
- Virus effect remover
- SuperAntiSpywarePro
- Trojan Remover Tool
- AVAST removal Tool
- McAfee Removal Tool
- K7 anti virus Removal Tool
- AVG remover 32
- AVG remover 64
- SymRegFix Tools For windows XP SP3 Registry error
- Norton removal Tool
- Kaspersky antivirus Removal Tool
- Norton removal Tool 2009 Products
- NO Disk Error in windows XP
- Microsoft® Windows® Malicious Software Removal Tool (KB890830)
Haup pauge TV tuner:
Install windows 8, Windows 7 and from a Bootable pen drive.
Hi all, i feel too happy to share the things i Know and i wish this will help someone somewhere.
Today, here is an article to create a bootable windows installation Pen drive. This will allow us to install newer versions of windows OS from this pen drive.
The steps given below are applicable for creating a windows Vista, Windows 7 and windows 8 Bootable USB disk.
Objective: Create a bootable windows(vista , windows 7, windows 8) installation USB disk.
Requirements:
1. A USB 2.0 or 3.0 pen drive 4GB or higher
2. Original windows installation DVD media or iso image.
3. A system with Vista, windows 7 or windows 8 operating system with DVD drive.
1.Preparation:
Today, here is an article to create a bootable windows installation Pen drive. This will allow us to install newer versions of windows OS from this pen drive.
The steps given below are applicable for creating a windows Vista, Windows 7 and windows 8 Bootable USB disk.
Objective: Create a bootable windows(vista , windows 7, windows 8) installation USB disk.
Requirements:
1. A USB 2.0 or 3.0 pen drive 4GB or higher
2. Original windows installation DVD media or iso image.
3. A system with Vista, windows 7 or windows 8 operating system with DVD drive.
In case you do not have any system having vista , 7 or windows 8 installed, still we can complete our task....
to do this, boot from windows vista, windows 7 or windows 8 disk, you can use any of the disks to prepare the pen drive.
after booting you will get the windows setup screen, now Press SHIFT+F10 key combination together and this will bring up command prompt on the screen, now you may follow the instructions below1.Preparation:
First we will prepare the pen drive, to do this open CMD (command prompt) with Administrative privileges and run the following commands.
note: this is clean all the data from pen drive, be sure to backup it first.
- Type Diskpart on command prompt
- Now type List volume, this will show all the partitions and drivers attached to pc. find the drive letter corresponding to you pen drive(in my case it is was F:)
- type select volume F
- now type clean (this will clean pen drive completely, deleting all partitions)
- now type create partition primary
- now type format fs=ntfs quick
- now type active
- the step above automatically assigns drive letter to pen drive, but if it doesn't then you the next command.
- assign letter="f"
- now type exit
note: Command prompt is still open and let it be, our pen drive is now ready.
2.Adding boot information.
using the command prompt, go to DVD drive and then Boot folder in windows installation DVD.
in my case E: is the DVD drive letter and prompt looks like this.(instead of E: use your DVD drive letter)
E:\
E:\BOOT>
now type the following command (f: is my pen drive letter)
bootsect.exe /nt60 f:
3.Copy.
Next step is to insert windows installation DVD and copy all the contents from your windows installation DVD to the pen drive. copy windows vista DVD if you wish to install Vista, use windows 7 disk if you wish to install 7 or use windows 8 DVD if you wish to use pen drive to install windows 8.
Yes!! and we are done!!...You can now easily boot from this pen drive and use it to install windows on and pc that support booting from Pen drive. Suitable for net books, laptops etc.
try and see if it works for you..... you may use these steps for Windows Vista, Windows 7 and Windows 8 as well.
Install Windows XP from Pen Drive without third party software
We have seen people looking for a simple solution to install Windows XP from pen drive just like they can now install windows Vista , 7 and windows 8. Well, i know one such solution exactly and i use it personally. but i never shared it though... so here it is , and i hope this will help.
Benefits:
so let's get started. i assume that you know computer and OS installation basics and have read the earlier article for preparing a bootable window Vista,7 or 8 Pen drive.
Let me explain first, given below are the steps that we will use for preparation.
Step1 : Prepare Window Vista, Window 7 or windows 8 Boot able pen drive.
Step2 : Install windows XP on a a test pc.
Step3 : Capture Windows XP image from C: partition of test pc.(using imageX.exe)
Step4 : Once the image is captured, it can be used for installation on other desktops or laptops etc.
Objective: Install windows XP from a bootable (windows) pen drive.
1: Click here and follow instructions to create a bootable windows installation drive.
2: Install a fresh copy of windows XP on a desktop computer using standard procedure. do not install any drivers or software. Shutdown your computer after first restart.
3: We will now need Microsoft ImageX
(Microsoft ImageX tool for windows.(download it from Microsoft site here) ImageX is a very tiny application which comes as part of WAIK (windows automated installation kit). download the latest iso file from the link here. its is a big image file but worth the download because we will use ImageX.exe for several different purposes. )
Time to capture the freshly installed windows XP image from C: partition. to do this follow the steps below.
and that's it!!, we are done creating a bootable pen drive that can be used to install windows Vista, windows 7 or windows 8 and Windows XP as well.
You might be wondering how to install windows XP? So here are the steps...
Explanation: to install windows XP on a fresh HDD, we will create a new partition and then after format it with NTFS. next we will make that partition active and bootable. Once done, next step would be to apply windows XP image captured earlier to the newly created partition and finally, restart PC normally.
Objective: Install windows XP from a bootable (windows) pen drive.
1. follow the steps below to create a new partition to install windows XP. (if you already have a partition created on the Hard drive.)
the above command will make the partition bootable with NTLDR.
and we are done now...!!
Close all windows and restart pc normally, you will be greeted with windows XP logo....
Now go ahead give it a try...and do not forget to share your experience... And while installing Win XP, if we change the priority of setup process through task manager (Shift+F10 then type taskmgr and press enter) to high then within 15 min Win-XP will install.
Benefits:
- Takes less than 5 minutes to install OS.
- Image Based installation much similar to Vista, 7 and 8 installation.
- Tools used are from Microsoft.(ImageX).
so let's get started. i assume that you know computer and OS installation basics and have read the earlier article for preparing a bootable window Vista,7 or 8 Pen drive.
Let me explain first, given below are the steps that we will use for preparation.
Step1 : Prepare Window Vista, Window 7 or windows 8 Boot able pen drive.
Step2 : Install windows XP on a a test pc.
Step3 : Capture Windows XP image from C: partition of test pc.(using imageX.exe)
Step4 : Once the image is captured, it can be used for installation on other desktops or laptops etc.
Objective: Install windows XP from a bootable (windows) pen drive.
1: Click here and follow instructions to create a bootable windows installation drive.
2: Install a fresh copy of windows XP on a desktop computer using standard procedure. do not install any drivers or software. Shutdown your computer after first restart.
3: We will now need Microsoft ImageX
(Microsoft ImageX tool for windows.(download it from Microsoft site here) ImageX is a very tiny application which comes as part of WAIK (windows automated installation kit). download the latest iso file from the link here. its is a big image file but worth the download because we will use ImageX.exe for several different purposes. )
Time to capture the freshly installed windows XP image from C: partition. to do this follow the steps below.
- Copy ImageX to bootable pen drive created during the Step1.
- Boot from bootable pen drive
- On the setup screen Press Shift+F10 to open command prompt.
- Now from command prompt go to pen drive.
- Now Type command Imagex /capture C: C:\WinXP.wim "XP"
- The above step will capture windows XP image from c: drive and save it with a file name Winxp.wim
- the process will take around 10-15 minutes.
- once done you may normally restart the pc.
- next step is to copy winxp.wim from c: drive to Pen drive
and that's it!!, we are done creating a bootable pen drive that can be used to install windows Vista, windows 7 or windows 8 and Windows XP as well.
You might be wondering how to install windows XP? So here are the steps...
Explanation: to install windows XP on a fresh HDD, we will create a new partition and then after format it with NTFS. next we will make that partition active and bootable. Once done, next step would be to apply windows XP image captured earlier to the newly created partition and finally, restart PC normally.
Objective: Install windows XP from a bootable (windows) pen drive.
1. follow the steps below to create a new partition to install windows XP. (if you already have a partition created on the Hard drive.)
- Boot from Pen drive created earlier
- on the setup screen press Shift+F10 to bring up Command prompt
- Type Diskpart on command prompt
- Now type List disk, this will show all the Physical Hard disk drive and other drivers attached to pc. find the disk corresponding to you HDD (in my case it is was Disk 1)
- type select disk 1
- now type create partition primary size=102400 ( mention required partition size in MB)
- now type format fs=ntfs quick
- now type active
- the step above automatically assigns drive letter to pen drive, but if it doesn't then you the next command.
- assign letter="C"
- now type exit
Now using the same command prompt got to the pen drive wherein we have our WinXP.wim and imagex.exe file.
now from the command prompt type the following commands.
imagex /apply WinXP.wim 1 C:\
C: is the drive letter on which we you wish to install OS.
now patiently wait for process to finish up. it would take around a minute or 2. you will be able to see the progress in the command prompt window.
2.Adding boot information to Windows Partition.
using the command prompt, go to Pen drive and then Boot folder. In my case E: is the Pen drive letter and prompt looks like this.(instead of E: use your Pen drive letter)
E:\
E:\BOOT>
now type the following command
bootsect.exe /nt52 C:
the above command will make the partition bootable with NTLDR.
and we are done now...!!
Close all windows and restart pc normally, you will be greeted with windows XP logo....
Now go ahead give it a try...and do not forget to share your experience... And while installing Win XP, if we change the priority of setup process through task manager (Shift+F10 then type taskmgr and press enter) to high then within 15 min Win-XP will install.
Solution -Windows 8 not detecting CD DVD drive
I have been through several forums and disscustion boards stating about an issue with windows 8 out of which the DVD /CD drives no longer get detected. well here is some explanation to it and a way to make it work if it is not working as expected.
http://msdn.microsoft.com/en-us/library/windows/hardware/jj591582.aspx
In order for ZPODD to work, the ZPODD feature must be supported by the optical drive, the motherboard, and the BIOS.
In some cases even after inserting a Disk in the drive, the drive icon still doesn't show up. you may follow the steps below to make that work.
1. Run Command Prompt as an Administrator. Directly type cmd in the new Start Screen(a.k.a Windows 8 Metro UI) and press cltr+shift+enter.
Now copy the following , right click command prompt and select paste and the Enter.
reg.exe add "HKLM\System\CurrentControlSet\Services\atapi\Controller0" /f /v EnumDevice1 /t REG_DWORD /d 0x00000001
2.Reboot the system
3.Verify if the problem has been resolved.
http://msdn.microsoft.com/en-us/library/windows/hardware/jj591582.aspx
Zero Power Optical Disk Drive
Zero Power Optical Disk Drive (Zero Power ODD or ZPODD) is one of many new Windows 8 features introduced for power efficiency. On a system enabled with ZPODD, when Windows 8 detects that there is no media in an optical drive, power to the optical drive is cut off. As soon as the user attempts to use the optical drive, power to the optical drive automatically resumes and the user will be able to use the optical drive immediately, unaware that the power to the device was ever turned off. Everything happens in the background and normal user interaction is not affected. ZPODD applies only to optical drives that use the slimline SATA connector and is typically found on laptops. Some servers and desktops also use a slimline SATA connector for optical drives.In order for ZPODD to work, the ZPODD feature must be supported by the optical drive, the motherboard, and the BIOS.
In some cases even after inserting a Disk in the drive, the drive icon still doesn't show up. you may follow the steps below to make that work.
1. Run Command Prompt as an Administrator. Directly type cmd in the new Start Screen(a.k.a Windows 8 Metro UI) and press cltr+shift+enter.
Now copy the following , right click command prompt and select paste and the Enter.
reg.exe add "HKLM\System\CurrentControlSet\Services\atapi\Controller0" /f /v EnumDevice1 /t REG_DWORD /d 0x00000001
2.Reboot the system
3.Verify if the problem has been resolved.
Subscribe to:
Posts (Atom)