Have you ever wondered how to get the path of the working directory?. To do that you can use the command: PWD . This simple order gives you precisely that, the working directory, for instance:
pwd > returns /home/user/dir
As always use the man command to get more info about the inner details of this easy but useful tool.
This couple of commands are really helpful. It allows you to easily navigate through the system without having to repeat long paths. For example, imagine that you are in the directory /user/data/data2/home/ but want to change to other directory for a moment, say /etc; you can do:
pushd /etc -> this will move to /etc and push our directory into the stack. After finish you job in /etc we can type:
popd -> this will bring us to the original directory
This is an interesting command. Have you ever wanted to be sure that just one instance of your app/script is running at the same time? Then, flock is your tool. The sintax is as follows:
This runs htop and uses a generated file in home/user named lockfile to control the locking. If you try to run the same command, you will not be able to run htop again until the first instance finish.
This is one of those extremely useful commands that not many people know. Basically runs a shell command and exits when the time runs out. The format is as follows:
timeout [OPTION] DURATION COMMAND [ARG]…
Lets see an example:
timeout 10s top : This starts the top utility waits for 10 seconds and quit. Simple. The sufixes are:
s for second
m for minutes
h for hours
d for days
As always, check the man page for more details and info.
Have you ever wonder who is in your system? and doing what? Well, beauty always comes in small packages and today it is not an exception, the only thing you need is: w .This small tool comes to the rescue. The format is as follows:
w [options] user […]
Lets see some examples:
w -> this command with no parameters shows you all the info you need. This is the output (depends on your system):
17:37:51 up 7:52, 1 user, load average: 0,44, 0,62, 0,69 USER TTY LOGIN@ IDLE JCPU PCPU WHAT user :0 09:45 ?xdm? 1:23m 0.00s /usr/libexec/gdm-x-session --run-script /usr/bin/gnome-session
lets see what we have here:
17:37:51 -> current time
up 7:52 -> how long the system has been running
1 user -> how many users are currently logged on
load average: 0,44, 0,62, 0,69 -> the load average the past 1, 5 and 15 minutes respectively
Then, for each user logged into the system we have one row showing:
user-> login name
:0 -> the tty name
From -> this field only appears if the user is connected through a remote ssh conection. In this example do not appears because the user is local
09:45 -> login time
?xdm? -> idle time (usually for remote users, if the user is local, shows xdm, the display manager)
JCPU -> is the time used by all processes attached to the tty
PCPU -> is the time used by the current process (the one in the what field)
/usr/libexec… -> command line of the current process
This command allows you to list files and directories (dir in Ms-dos world). Lets see how this works.
The format is as follows:
ls [OPTION]… [FILE]…
You can type ls as is to show a barebones listing of files and directories. Lets see more possibilities:
ls -l -> this shows the long listing format (its a compact way to show the info)
ls -a -> shows only the hidden files (the ones starting with a dot)
ls -la -> shows all files in listing format plus, the hidden ones
ls -i -> shows inode information about the files (info about the file system)
la -lh -> shows files and details in human readable format
ls -lha -> You get the idea, you can combine the options to get the result that you want, with this you get details in human readable format plus hidden files
As you can see there are many combinations. Those here are just a tiny fraction of what is possible with this command. If you want more info, type man ls to see the full list of options.
To choose a programming language is always a difficult task. In theory it is just a tool to solve a problem but in practice it is much more than that. Platforms, library support, community etc can greatly influence the time and effort to develop a product, I have tried many programming languages and in general I would say there is a clear improvement Lately. First I thought javascript would be the only language to rule them all, but after a few years dealing with extremely fast moving frameworks, excessive complexities of the language itself -think about the craziness of “this”– and a bunch of patches in the form of a thousands tools to deal with what the language was not designed for I quit.
Looking for a replacement I tried Go but it was not my cup of tea. I like many things about Go -simplicity- but I also dislike a lot, like the tediousness of some tasks, no class system etc. Rust is too complex for my liking -see c++– and I do not like Java either. There are a few newcomers that can bring hope though: kotlin and Dart:
I have always wanted a better language for general computing and I think Dart fits the sweet spot between capabilities and easiness of use. Kotlin offers the same but in another level, It is a much more rich and complex language. I will be trying both and sharing my experiences.
Anyway, maybe the point it is not about the language itself but the results: things like the graalvm virtual machine .net o wasm are the way to go. Pick the language of your choice, be Go,Rust, C#,ruby etc and let the virtual machine do the rest, support, libraries etc.