Testing TCP connection
Create TCP listener:
$ nc -l 9999
Create TCP Client:
$ nc -vt 192.168.5.12 9999
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Connected to 192.168.5.12:9999.
Testing UDP connection
Create UDP listener:
$ nc -ul 9999
Create UDP Client:
$ nc -vu 192.168.5.12 9999
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Connected to 192.168.5.12:9999.
Test UDP Connection...
Monday, November 28, 2016
Friday, November 4, 2016
Thursday, November 3, 2016
sysctl to change kernel system settings
To list all settings configurable in the /proc/sys/ directory:
/sbin/sysctl
-a
To assign values to writable files in the
/proc/sys/ directory:
sysctl -w [parameter] = [value]
Example:
sysctl -w kernel.sysrq="1"
This only works for testing purposes. Special settings within /proc/sys/ are lost when the
machine is rebooted. To preserve custom settings, add them to the /etc/sysctl.conf...
IPC Queues - ENOSPC (No space left on device) error
ENOSPC returns from msgget indicates that the system-wide maximum number of message queues has been reached.
Solution:
Change this limit editing:
/proc/sys/kernel/msg...
Thursday, October 27, 2016
List the contents of a compressed file without extracting all the files
tar file:
$ tar -tvf file.tar.gz
tar.gz file:
$ tar -ztvf file.tar.gz
tar.bz2 file
$ tar -jtvf file.tar.bz2
List only specific files:
$ tar -tvf file.tar 'pattern'
Where,
t: List the contents.
f: process the following file name.
v: show detailed information.
z: process tar.gz files.
j: process tar.bz2 files....
Wednesday, October 26, 2016
Verify file integrity with md5
md5sum [file1 file2 file3 ...] > file.md5
where:
[file1 file file3 ...]: files you want to check integrity separated by a space.
file.md5: file where you want to save the md5 results.
Example:
md5sum file1 file2 > file.md5
md5sum -c file.md5
file1: OK
file2:...
Saturday, October 22, 2016
Gnome desktop does not start up due to selinux permission
Edit the following file:
/etc/selinux/config
Set SELINUX to disable.
vim /etc/selinux/config
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
After editing:
SELINUX=disab...
Wednesday, September 21, 2016
Sunday, September 11, 2016
My CLI CheatSheet
Shorcuts
Ctrl + W - Erase one word in the current line.
!! - Repeats the last command.
Ctrl + Z - Stops the current command,
Ctrl + D - Log out of current session, similar to exit.
Ctrl + K - Deletes from the cursor to the end of the line.
Ctrl + R - Type to bring up a recent command.
Ctrl + U - Deletes from the cursor back to the line start.
...
Wednesday, August 24, 2016
Edit command from the history list with vi or emacs using fc
fc command is used to edit, re-execute and list previously entered commands from the history list.
With fc you can made a quick open of your favorite editor and edit a previously entered command.
If the command you want to edit just has been resently executed just type:
fc
This open the default editor with the command to edit inside.
Execute with the option -e to choose the editor you want....
Friday, August 12, 2016
Git - Revert master branch to a former commit
Do this:
git checkout master
git reset --hard [Tag Code]
git push --force origin master
Where:
[Tag Code]: is the tag code of the comm...
Thursday, July 7, 2016
Screen command quick start guide
To create a new session, write the following with your session name instead of [session]:
screen -R [session]
This will start a new session with name [session](if not created before) in a new clean "screen".
To dettach the session just press:
Ctrl + a (realease keys) d
To attach the screen session again, write again:
screen -R [session]
To list all the screen sessions:
screen...
Tuesday, July 5, 2016
Command line history
The history command can be used to list all the previous commands you have typed before. The syntax is as following:
history n
where n is the number of commands you have typed before.
Example:
This lists the last 5 commands typed before:
$ history 5
510 cp /home/pepito/myfile /home/pepito/myfolder
511 ls
512 ip addr show
513 ifconfig
514 history 5
You can select to execute a command...
Shortcuts to cut, copy & paste on a terminal command line
Ctrl + u : Deletes from the cursor back to the line start.
.
Ctrl + k : Deletes from the cursor to the end of the line.
Ctrl + w : Deletes until after the previous word boundary.
Alt + d : Deletes until before the next word boundary.
Ctrl + y : Yank/Past the previous killed text at he cursor position.
Alt + y :...
Compress and Extract gz, .tar.gz, and .zip
Compress and Extract gz, .tar.gz, and .zip
.tar.gz:
Compress: tar -czvf file.tar.gz folder/to/compress/
Extract: tar -xzvf file.tar.gz
.tar:
Compress: tar -cvf file.tar folder/to/compress/
Extract: tar -xvf file.tar
.gz:
Compress: gzip -9 file
Extract: gzip -d file.gz
.zip:
Compress: zip file.zip folder/to/compress/
Extract: unzip file.z...
Monday, July 4, 2016
SIOCDELRT error when try to delete a single route from route table
If you want to delete a single route from the route table, you have to specify enough parameters to make this route unique.
For example, this gives you an error, because the mask is not specified:
$ sudo route del -net 192.168.5.0
SIOCDELRT: No such process
This gives you a successful output, because the mask is properly specified:
$ sudo route del -net 192.168.5.0/24
...
Friday, July 1, 2016
Git - Delete files from remote repository which are already deleted from your local filesystem
Go to the main project directory and execute:
$ git ls-files --deleted -z | xargs -0 git...
Tuesday, June 28, 2016
Git - Get new recently added files but yet not commited
The following command gets all the files that you recently added but not commited yet:
$ git diff --cached --name-only --diff-filter=A
Details:
--name-only: shows all the files you changed relative to HEAD.
--name-status: to get the status symbol too.
--diff-filter=A: shows only the new recently added fil...
Monday, June 27, 2016
VMware - Fix copy and paste between host and guest
Try to reinstall VMware Tools. Follow the instructions from:
https://www.vmware.com/support/ws55/doc/new_guest_tools_ws.h...
Erase all files/directories except some of them
To erase all directories except one, execute the following:
$ find . -maxdepth 1 -not -name [file/directory_name] -exec rm -R {} \;
Where:
-maxdepth: prevents to erase recursively inside the directory to keep.
If you want to be sure that the correct files will be removed, run first the beginning part of the command(before "-exec") and when you are sure, execute the complete command:
$ find ....
Shortcuts to move the cursor on a terminal command line
Ctrl + a : Moves the cursor to the line start.
.
Ctrl + e : Moves the cursor to the line end (remember e for end).
Alt + f : Moves the cursor forward one word (remember f for forward) .
Alt + b : Moves the cursor backward one word (remember b for backward) .
Ctrl + x + x: Moves the cursor to the line start and to the end...
Friday, June 24, 2016
Thursday, June 23, 2016
Git - Checking changes on origin repository against your local
Make a fetch to update the remote branch latest version status in your repository:
$ git fetch origin [Your remote branch]
fetch does not change anything in your local repository, only updates the information against the branch selected.
Check differences with diff:
$ git diff origin/[Your remote branch...
Wednesday, June 22, 2016
Git - Commit project to new branch
Create a new branch and move your project to it:
$ git checkout -b [New Branch]
If you have modified or created files, add them to the project:
$ git add [Your modified or new files]
Commit your changes:
$ git commit -m '[Your Comments]'
Push the project to the new branch:
$ git push origin [New Branch]
See also:
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merg...
Monday, June 13, 2016
Uninstall driver from unixODBC using odbcinst
To uninstall driver from unixODBC using odbcinst, execute:
$ sudo odbcinst -u -d -n [Driver_name]
FreeTDS has been deleted (if it existed at all) because its usage count
became ze...
Uninstall DSN from unixODBC using odbcinst
To uninstall a DSN from unixODBC use:
$ odbcinst -u -s -n [your_DSN_name]
odbcinst: DSN removed (if it existed at all). ODBC_BOTH_DSN was used as
the search path...
Friday, June 10, 2016
Install Sublime Text 3
Download Sublime Text 3:
wget https://download.sublimetext.com/sublime_text_3_build_3114_x64.tar.bz2
Uncompress tarball:
sudo tar vxjf sublime_text_3_build_3114_x64.tar.bz2
Move sublime directory to /opt:
sudo mv sublime_text_3 /opt/
Create symbolic link to sublime:
sudo ln -s /opt/sublime_text_3/sublime_text /usr/bin/sublime
Execute sublime and enjoy!:
subl...
Thursday, June 9, 2016
Git - Usefull commands
- Delete branch of current project:
git remote remove origin
- Add current project to a branch:
git remote add origin [remote repository]
- Clone a specific branch:
git clone -b [branch] [remote reposito...
Git - Steps to commit a project
1. Show the status(how many new files, deleted files, modified files, etc.):
$ git status
2. Add all files to the project:
$ git add -A
the -A option means track all including deleted files.
3. Commit:
$ git commit -m "[Comments]"
the -m option gives you the possibility to add your comments in the same line.
4. Push:
$ git push -u origin master
The -u is optional and what it does is sets your...
Thursday, May 19, 2016
Copy command output data to standard output and to a file
Use the tee command:
$ [COMMAND] | tee [OUTPUT.FILE]
Where:
[COMMAND] is the command you want to execute.
[OUTPUT.FILE] is the file you want to write in.
Variation for writing the standard error output:
$ [COMMAND] 2>&1 | tee [OUTPUT.FILE]
Where:
[COMMAND] is the command you want to execute.
[OUTPUT.FILE] is the file you want to...
Monday, May 9, 2016
How to chown/chmod all files in current directory recursively?
# chown -R username:groupname *
will change username and groupname on all files and subdirectories recursively(all subdirectories which are inside subdirectories and all files inside the...
Wednesday, March 30, 2016
Configure password-based login for root
By default, the SSH server denies password-based login for root. In /etc/ssh/sshd_config, change:
PermitRootLogin without-password
to
PermitRootLogin yes
And restart SSH:
sudo service ssh restart
Or, you can use SSH keys. If you don't have one, create one using ssh-keygen (stick to the default for the key, and skip the password if you feel like it). Then do sudo -s (or whatever your...
Tuesday, March 29, 2016
Delete files and directories which are more than one day older
To erase files older than 24 hours ago:
find . -mmin +1440 -exec rm -fr {} \
24 hours = 24 * 60 minutes = 1440 minu...
Find files older than certain minutes ago
Example:
To find files older than 360 minutes ago:
find $PATH -name $FILES -type f -mmin +360
...
Popular Posts
-
The man page says: EINVAL A new segment was to be created and size < SHMMIN or size > SHMMAX, or no new segment was to be created, ...
-
To swap column 2 and 3 in a 4 column file: awk -F, '{print $1,$3,$2,$4}' OFS=; " FILE " > NEW_FILE where: OFS: ind...
-
Write the web service's response(xml, json, plain text) in a file, and then run the following in a terminal: $ while true; do echo -e...
-
If you want to delete a single route from the route table, you have to specify enough parameters to make this route unique. For example, t...
-
ENOSPC returns from msgget indicates that the system-wide maximum number of message queues has been reached. Solution: Change this lim...
-
To uninstall driver from unixODBC using odbcinst, execute: $ sudo odbcinst -u -d -n [ Driver_name ] FreeTDS has been deleted (if it existed...
-
Designed by Freepik You have a group of files and some of them are compressed with zip or gz and you want to search for a specific tex...
-
Shorcuts Ctrl + W - Erase one word in the current line. !! - Repeats the last command. Ctrl + Z - Stops the current command, Ctr...
-
The history command can be used to list all the previous commands you have typed before. The syntax is as following: history n where n ...
-
To erase files older than 24 hours ago: find . -mmin +1440 -exec rm -fr {} \ 24 hours = 24 * 60 minutes = 1440 minutes
Recent Posts
Categories
.bash
.bashrc
action
awk
bash
branch
changes
chmod
chown
color
column
command line
commands
commit
compress
compress files
compressed
config
console
convert
copy
CR-LF
create
cut
delete
desktop
diff
directories
directory
dos
driver
erase
error
etc
except
exclude
extract files
fetch
find
format
git
gnome
gz
hash
hostname
init.d
install
integrity
ipc
kernel
linux
list
ls
md5
mock
msgget
mysql
netcat
networking
newlines
odbc
odbcinst
openvpn
owner
passwd
paste
permissions
queue
quick guide
rc.d
readline
reboot
recursively
redhat
release
remove
rm
route
routing
scp
screen
script
selinux
shell
shmget
shortcuts
shutdown
SIOCDELRT
start
stderr
stdout
sublime text
sublime text 3
swap
sysctl
tail
tar
tar.gz
tcp
tcpdump
tee
terminal
test
truncate
udp
uname
uninstall
unixODBC
user
useradd
version
view
vpn
webservice
zgrep
zip
Unordered List
Text Widget
Pages
Blog Archive
-
▼
2016
(40)
-
►
June
(14)
- Git - Get new recently added files but yet not com...
- VMware - Fix copy and paste between host and guest
- Erase all files/directories except some of them
- Shortcuts to move the cursor on a terminal command...
- Create a new user
- Get RedHat version
- Git - Checking changes on origin repository agains...
- Git - Commit project to new branch
- Uninstall driver from unixODBC using odbcinst
- Uninstall DSN from unixODBC using odbcinst
- Reload .bashrc without logging out and logging in
- Install Sublime Text 3
- Git - Usefull commands
- Git - Steps to commit a project
-
►
June
(14)
About Me
Search This Blog
Powered by Blogger.